diff --git a/fs/accounting/stats.go b/fs/accounting/stats.go index d31b23158..36818b01b 100644 --- a/fs/accounting/stats.go +++ b/fs/accounting/stats.go @@ -532,3 +532,16 @@ func (s *StatsInfo) AddTransfer(transfer *Transfer) { s.startedTransfers = append(s.startedTransfers, transfer) s.mu.Unlock() } + +// RemoveTransfer removes a reference to the started transfer. +func (s *StatsInfo) RemoveTransfer(transfer *Transfer) { + s.mu.Lock() + for i, tr := range s.startedTransfers { + if tr == transfer { + // remove the found entry + s.startedTransfers = append(s.startedTransfers[:i], s.startedTransfers[i+1:]...) + break + } + } + s.mu.Unlock() +} diff --git a/fs/accounting/transfer.go b/fs/accounting/transfer.go index a7015b918..41a5536b3 100644 --- a/fs/accounting/transfer.go +++ b/fs/accounting/transfer.go @@ -113,6 +113,7 @@ func (tr *Transfer) Done(err error) { } else { tr.stats.DoneTransferring(tr.remote, err == nil) } + tr.stats.RemoveTransfer(tr) } // Reset allows to switch the Account to another transfer method.