"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: stop averaging when the last check finishes
Kunpeng Xie4f0148db0c37
diff --git a/fs/accounting/stats.go b/fs/accounting/stats.goindex f86c809d2..51a1f2647 100644--- a/fs/accounting/stats.go+++ b/fs/accounting/stats.go@@ -831,6 +831,9 @@ func (s *StatsInfo) DoneChecking(remote string) {s.checking.del(remote)s.mu.Lock()s.checks+++ if s.transferring.empty() && s.checking.empty() {+ s._stopAverageLoop()+ }s.mu.Unlock()}diff --git a/fs/accounting/stats_test.go b/fs/accounting/stats_test.goindex 317cd07cd..d08cd3222 100644--- a/fs/accounting/stats_test.go+++ b/fs/accounting/stats_test.go@@ -9,10 +9,33 @@ import ("github.com/rclone/rclone/fs""github.com/rclone/rclone/fs/fserrors"+ "github.com/rclone/rclone/fstest/mockobject""github.com/stretchr/testify/assert""github.com/stretchr/testify/require")+func TestAverageLoopStopsAfterLastCheck(t *testing.T) {+ ctx := context.Background()+ stats := NewStats(ctx)+ t.Cleanup(func() {+ stats.mu.Lock()+ defer stats.mu.Unlock()+ stats._stopAverageLoop()+ })+ transfer := stats.NewTransferRemoteSize("transfer", 0, nil, nil)+ firstCheck := stats.NewCheckingTransfer(mockobject.New("first"), "checking")+ lastCheck := stats.NewCheckingTransfer(mockobject.New("last"), "checking")++ transfer.Done(ctx, nil)+ firstCheck.Done(ctx, nil)+ assert.True(t, stats.average.started, "a check is still active")++ lastCheck.Done(ctx, nil)+ assert.False(t, stats.average.started, "completed checks must release the averaging goroutine")+ assert.Equal(t, int64(2), stats.GetChecks())+ assert.Equal(t, int64(1), stats.GetTransfers())+}+func TestETA(t *testing.T) {for _, test := range []struct {size, total int64