"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
acounting: fix incorrect speed and transferTime in core/stats
Nick Craig-Wood5c49096e116e
diff --git a/fs/accounting/stats_groups.go b/fs/accounting/stats_groups.goindex 6bcd1ea20..776af484c 100644--- a/fs/accounting/stats_groups.go+++ b/fs/accounting/stats_groups.go@@ -366,6 +366,8 @@ func (sg *statsGroups) sum() *StatsInfo {sum.lastError = stats.lastError}sum.startedTransfers = append(sum.startedTransfers, stats.startedTransfers...)+ sum.oldDuration += stats.oldDuration+ sum.oldTimeRanges = append(sum.oldTimeRanges, stats.oldTimeRanges...)}stats.mu.RUnlock()}diff --git a/fs/accounting/stats_groups_test.go b/fs/accounting/stats_groups_test.goindex 76d93bf64..224dff9ef 100644--- a/fs/accounting/stats_groups_test.go+++ b/fs/accounting/stats_groups_test.go@@ -4,8 +4,10 @@ import ("fmt""runtime""testing"+ "time""github.com/rclone/rclone/fstest/testy"+ "github.com/stretchr/testify/assert")func TestStatsGroupOperations(t *testing.T) {@@ -43,17 +45,26 @@ func TestStatsGroupOperations(t *testing.T) {t.Parallel()stats1 := NewStats()stats1.bytes = 5- stats1.errors = 5+ stats1.errors = 6+ stats1.oldDuration = time.Second+ stats1.oldTimeRanges = []timeRange{{time.Now(), time.Now().Add(time.Second)}}stats2 := NewStats()+ stats2.bytes = 10+ stats2.errors = 12+ stats2.oldDuration = 2 * time.Second+ stats2.oldTimeRanges = []timeRange{{time.Now(), time.Now().Add(2 * time.Second)}}sg := newStatsGroups()sg.set("test1", stats1)sg.set("test2", stats2)sum := sg.sum()- if sum.bytes != stats1.bytes+stats2.bytes {- t.Fatalf("sum() => bytes %d, expected %d", sum.bytes, stats1.bytes+stats2.bytes)- }- if sum.errors != stats1.errors+stats2.errors {- t.Fatalf("sum() => errors %d, expected %d", sum.errors, stats1.errors+stats2.errors)+ assert.Equal(t, stats1.bytes+stats2.bytes, sum.bytes)+ assert.Equal(t, stats1.errors+stats2.errors, sum.errors)+ assert.Equal(t, stats1.oldDuration+stats2.oldDuration, sum.oldDuration)+ // dict can iterate in either order+ a := timeRanges{stats1.oldTimeRanges[0], stats2.oldTimeRanges[0]}+ b := timeRanges{stats2.oldTimeRanges[0], stats1.oldTimeRanges[0]}+ if !assert.ObjectsAreEqual(a, sum.oldTimeRanges) {+ assert.Equal(t, b, sum.oldTimeRanges)}})