From 34f03ce5900d9a6c8202a2a865e154596580aa90 Mon Sep 17 00:00:00 2001 From: Garry McNulty Date: Tue, 28 May 2019 19:51:25 +0100 Subject: [PATCH] operations: ignore negative sizes when calculating total (#3135) --- fs/operations/operations.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/operations/operations.go b/fs/operations/operations.go index 5d15e80c6..b91e168c2 100644 --- a/fs/operations/operations.go +++ b/fs/operations/operations.go @@ -960,7 +960,10 @@ func HashLister(ht hash.Type, f fs.Fs, w io.Writer) error { func Count(f fs.Fs) (objects int64, size int64, err error) { err = ListFn(f, func(o fs.Object) { atomic.AddInt64(&objects, 1) - atomic.AddInt64(&size, o.Size()) + objectSize := o.Size() + if objectSize > 0 { + atomic.AddInt64(&size, objectSize) + } }) return }