operations: ignore negative sizes when calculating total (#3135)

This commit is contained in:
Garry McNulty 2019-05-28 19:51:25 +01:00 committed by Nick Craig-Wood
parent e2fde62cd9
commit 34f03ce590

View File

@ -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
}