mirror of
https://github.com/rclone/rclone.git
synced 2024-12-22 23:22:08 +01:00
accounting: fix unknown length file transfers count 3 transfers each #6213
This was caused by nested calls to NewTransfer/Done. This fixes the problem by only incrementing transfers if the remote is present in the transferMap which means we only increment it once.
This commit is contained in:
parent
fdd2f8e6d2
commit
517e7d9271
@ -714,10 +714,10 @@ func (s *StatsInfo) NewTransferRemoteSize(remote string, size int64) *Transfer {
|
||||
|
||||
// DoneTransferring removes a transfer from the stats
|
||||
//
|
||||
// if ok is true then it increments the transfers count
|
||||
// if ok is true and it was in the transfermap (to avoid incrementing in case of nested calls, #6213) then it increments the transfers count
|
||||
func (s *StatsInfo) DoneTransferring(remote string, ok bool) {
|
||||
s.transferring.del(remote)
|
||||
if ok {
|
||||
existed := s.transferring.del(remote)
|
||||
if ok && existed {
|
||||
s.mu.Lock()
|
||||
s.transfers++
|
||||
s.mu.Unlock()
|
||||
|
@ -34,10 +34,13 @@ func (tm *transferMap) add(tr *Transfer) {
|
||||
}
|
||||
|
||||
// del removes a transfer from the map by name
|
||||
func (tm *transferMap) del(remote string) {
|
||||
func (tm *transferMap) del(remote string) bool {
|
||||
tm.mu.Lock()
|
||||
_, exists := tm.items[remote]
|
||||
delete(tm.items, remote)
|
||||
tm.mu.Unlock()
|
||||
|
||||
return exists
|
||||
}
|
||||
|
||||
// merge adds items from another map
|
||||
|
Loading…
Reference in New Issue
Block a user