"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
accounting: keep speed averaging active when transfers overlap
kaii9aa308e3d7c92
diff --git a/fs/accounting/stats.go b/fs/accounting/stats.goindex 51a1f2647..53a837314 100644--- a/fs/accounting/stats.go+++ b/fs/accounting/stats.go@@ -873,15 +873,13 @@ func (s *StatsInfo) NewTransferRemoteSize(remote string, size int64, srcFs, dstF// if ok is true and it was in the transfermap (to avoid incrementing in case of nested calls, #6213) then it increments the transfers countfunc (s *StatsInfo) DoneTransferring(remote string, ok bool) {existed := s.transferring.del(remote)+ s.mu.Lock()+ defer s.mu.Unlock()if ok && existed {- s.mu.Lock()s.transfers++- s.mu.Unlock()}if s.transferring.empty() && s.checking.empty() {- s.mu.Lock()s._stopAverageLoop()- s.mu.Unlock()}}diff --git a/fs/accounting/stats_test.go b/fs/accounting/stats_test.goindex d08cd3222..a7d38c433 100644--- a/fs/accounting/stats_test.go+++ b/fs/accounting/stats_test.go@@ -4,6 +4,7 @@ import ("context""fmt""io"+ "sync""testing""time"@@ -14,6 +15,38 @@ import ("github.com/stretchr/testify/require")+func TestAverageLoopTransferOverlap(t *testing.T) {+ ctx := context.Background()+ stats := NewStats(ctx)+ t.Cleanup(func() {+ stats.mu.Lock()+ defer stats.mu.Unlock()+ stats._stopAverageLoop()+ })+ current := stats.NewTransferRemoteSize("initial", 1, nil, nil)+ for i := range 10000 {+ start := make(chan struct{})+ var next *Transfer+ var wg sync.WaitGroup+ wg.Go(func() {+ <-start+ current.Done(ctx, nil)+ })+ wg.Go(func() {+ <-start+ next = stats.NewTransferRemoteSize(fmt.Sprintf("transfer-%d", i), 1, nil, nil)+ })+ close(start)+ wg.Wait()+ stats.mu.Lock()+ started := stats.average.started+ stats.mu.Unlock()+ require.True(t, started, "transfer %d is active", i)+ current = next+ }+ current.Done(ctx, nil)+}+func TestAverageLoopStopsAfterLastCheck(t *testing.T) {ctx := context.Background()stats := NewStats(ctx)