Merge pull request #563 from tomekkolo/usedPercent_calculation_fix

Fixing calculation of UsedPercent.
tags/v2.18.07
shirou 7 years ago committed by GitHub
commit 8b14be0b8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -47,10 +47,10 @@ func UsageWithContext(ctx context.Context, path string) (*UsageStat, error) {
ret.InodesUsedPercent = (float64(ret.InodesUsed) / float64(ret.InodesTotal)) * 100.0
}
if ret.Total == 0 {
if (ret.Used + ret.Free) == 0 {
ret.UsedPercent = 0
} else {
ret.UsedPercent = (float64(ret.Used) / float64(ret.Total)) * 100.0
ret.UsedPercent = (float64(ret.Used) / float64(ret.Used+ret.Free)) * 100.0
}
return ret, nil

Loading…
Cancel
Save