diff --git a/b2/b2.go b/b2/b2.go index b7a300345..fcdf8abf9 100644 --- a/b2/b2.go +++ b/b2/b2.go @@ -799,9 +799,9 @@ func (f *Fs) purge(oldOnly bool) error { go func() { defer wg.Done() for object := range toBeDeleted { - fs.Stats.Transferring(object.Name) + fs.Stats.Checking(object.Name) checkErr(f.deleteByID(object.ID, object.Name)) - fs.Stats.DoneTransferring(object.Name) + fs.Stats.DoneChecking(object.Name) } }() } diff --git a/fs/accounting.go b/fs/accounting.go index 39b863f72..3f1e9b296 100644 --- a/fs/accounting.go +++ b/fs/accounting.go @@ -231,11 +231,15 @@ func (s *StatsInfo) Transferring(remote string) { } // DoneTransferring removes a transfer from the stats -func (s *StatsInfo) DoneTransferring(remote string) { +// +// if ok is true then it increments the transfers count +func (s *StatsInfo) DoneTransferring(remote string, ok bool) { s.lock.Lock() defer s.lock.Unlock() delete(s.transferring, remote) - s.transfers++ + if ok { + s.transfers++ + } } // Account limits and accounts for one transfer diff --git a/fs/operations.go b/fs/operations.go index ed49d587a..c6aad3c71 100644 --- a/fs/operations.go +++ b/fs/operations.go @@ -1017,8 +1017,11 @@ func CleanUp(f Fs) error { func Cat(f Fs, w io.Writer) error { var mu sync.Mutex return ListFn(f, func(o Object) { + var err error Stats.Transferring(o.Remote()) - defer Stats.DoneTransferring(o.Remote()) + defer func() { + Stats.DoneTransferring(o.Remote(), err == nil) + }() mu.Lock() defer mu.Unlock() in, err := o.Open() @@ -1041,5 +1044,4 @@ func Cat(f Fs, w io.Writer) error { ErrorLog(o, "Failed to send to output: %v", err) } }) - } diff --git a/fs/sync.go b/fs/sync.go index cdb152d17..8521984bc 100644 --- a/fs/sync.go +++ b/fs/sync.go @@ -232,12 +232,14 @@ func (s *syncCopyMove) pairCopier(in ObjectPairChan, fdst Fs, wg *sync.WaitGroup } src := pair.src Stats.Transferring(src.Remote()) + var err error if Config.DryRun { Log(src, "Not copying as --dry-run") } else { - s.processError(Copy(fdst, pair.dst, src)) + err = Copy(fdst, pair.dst, src) + s.processError(err) } - Stats.DoneTransferring(src.Remote()) + Stats.DoneTransferring(src.Remote(), err == nil) case <-s.abort: return } @@ -259,6 +261,7 @@ func (s *syncCopyMove) pairMover(in ObjectPairChan, fdst Fs, wg *sync.WaitGroup) if !ok { return } + transferredOK := true src := pair.src dst := pair.dst Stats.Transferring(src.Remote()) @@ -267,6 +270,7 @@ func (s *syncCopyMove) pairMover(in ObjectPairChan, fdst Fs, wg *sync.WaitGroup) err := Copy(fdst, dst, src) s.processError(err) if err != nil { + transferredOK = false ErrorLog(src, "Not deleting as copy failed: %v", err) } else { // Delete src if no error on copy @@ -293,6 +297,7 @@ func (s *syncCopyMove) pairMover(in ObjectPairChan, fdst Fs, wg *sync.WaitGroup) Stats.Error() ErrorLog(dst, "Couldn't move: %v", err) s.processError(err) + transferredOK = false } } else { Debug(src, "Moved") @@ -300,7 +305,7 @@ func (s *syncCopyMove) pairMover(in ObjectPairChan, fdst Fs, wg *sync.WaitGroup) } else { doCopy() } - Stats.DoneTransferring(src.Remote()) + Stats.DoneTransferring(src.Remote(), transferredOK) case <-s.abort: return }