From b1b5e09081060128c9bbf37315bd1359e4dde3a3 Mon Sep 17 00:00:00 2001 From: Yves G Date: Sat, 29 Feb 2020 15:07:45 +0100 Subject: [PATCH] vfs: make `df` output more consistent on a rclone mount. When 2 values are known among vfs:{free,used,total}, compute the 3rd --- vfs/vfs.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/vfs/vfs.go b/vfs/vfs.go index 58e7630b1..ccd10265c 100644 --- a/vfs/vfs.go +++ b/vfs/vfs.go @@ -510,6 +510,15 @@ func (vfs *VFS) Statfs() (total, used, free int64) { if u.Used != nil { used = *u.Used } + if total < 0 && free >= 0 && used >= 0 { + total = free + used + } + if free < 0 && total >= 0 && used >= 0 { + free = total - used + } + if used < 0 && total >= 0 && free >= 0 { + used = total - free + } } return }