From 867712f9437ae7ebd85e945968ea97ce51df83b3 Mon Sep 17 00:00:00 2001 From: Gary Date: Fri, 13 Nov 2026 09:08:00 +0100 Subject: [PATCH] fix(storage): a disk without partitions keeps its own fsused A filesystem made on the whole disk (/dev/sdd, no partition) has no children, so the loop summed 0 and overwrote lsblk's fsused with it: the API reported used=0 and the usage bar stayed empty. Only replace fsused with the children's sum when there are children. Reported in CasaOS#142. --- service/disk.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/service/disk.go b/service/disk.go index e2a120b..bd40ed1 100644 --- a/service/disk.go +++ b/service/disk.go @@ -338,7 +338,11 @@ func (d *diskService) LSBLK(isUseCache bool) []model.LSBLKModel { blk.Health = "OK" } - blk.FSUsed = json.Number(fmt.Sprintf("%d", fsused)) + // A disk with no partitions carries its own filesystem: keep lsblk's + // fsused instead of replacing it with the (empty) sum of its children. + if len(blk.Children) > 0 { + blk.FSUsed = json.Number(fmt.Sprintf("%d", fsused)) + } blk.Children = blkChildren if fsused > 0 { blk.UsedPercent, err = strconv.ParseFloat(fmt.Sprintf("%.4f", float64(fsused)/float64(blk.Size)), 64)