fix(drivers): free space underflow if used larger than total space (#1407)

This commit is contained in:
NewbieOrange
2025-10-04 00:41:45 +08:00
committed by GitHub
parent 6fe9af7819
commit 4153245f2c
7 changed files with 13 additions and 24 deletions

View File

@@ -61,6 +61,13 @@ type DiskUsage struct {
FreeSpace uint64 `json:"free_space"`
}
func NewDiskUsageFromUsedAndTotal(used, total uint64) *DiskUsage {
return &DiskUsage{
TotalSpace: max(used, total),
FreeSpace: total - min(used, total),
}
}
type StorageDetails struct {
DiskUsage
}