Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

stats: fix missing StatsInfo fields in the computation of the group sum

Carlo Mion7b7d780fffd8
diff --git a/fs/accounting/stats.go b/fs/accounting/stats.go
index fe1fdf11c..b4b32a8ee 100644
--- a/fs/accounting/stats.go
+++ b/fs/accounting/stats.go
@@ -24,6 +24,8 @@ const (
var MaxCompletedTransfers = 100
// StatsInfo accounts all transfers
+// N.B.: if this struct is modified, please remember to also update sum() function in stats_groups
+// to correctly count the updated fields
type StatsInfo struct {
mu sync.RWMutex
ctx context.Context
diff --git a/fs/accounting/stats_groups.go b/fs/accounting/stats_groups.go
index 400c72924..28548cfc9 100644
--- a/fs/accounting/stats_groups.go
+++ b/fs/accounting/stats_groups.go
@@ -359,23 +359,31 @@ func (sg *statsGroups) sum(ctx context.Context) *StatsInfo {
{
sum.bytes += stats.bytes
sum.errors += stats.errors
+ if sum.lastError == nil && stats.lastError != nil {
+ sum.lastError = stats.lastError
+ }
sum.fatalError = sum.fatalError || stats.fatalError
sum.retryError = sum.retryError || stats.retryError
+ if stats.retryAfter.After(sum.retryAfter) {
+ // Update the retryAfter field only if it is a later date than the current one in the sum
+ sum.retryAfter = stats.retryAfter
+ }
sum.checks += stats.checks
+ sum.checking.merge(stats.checking)
+ sum.checkQueue += stats.checkQueue
+ sum.checkQueueSize += stats.checkQueueSize
sum.transfers += stats.transfers
+ sum.transferring.merge(stats.transferring)
+ sum.transferQueueSize += stats.transferQueueSize
+ sum.renames += stats.renames
+ sum.renameQueue += stats.renameQueue
+ sum.renameQueueSize += stats.renameQueueSize
sum.deletes += stats.deletes
sum.deletedDirs += stats.deletedDirs
- sum.renames += stats.renames
- sum.checking.merge(stats.checking)
- sum.transferring.merge(stats.transferring)
sum.inProgress.merge(stats.inProgress)
- if sum.lastError == nil && stats.lastError != nil {
- sum.lastError = stats.lastError
- }
sum.startedTransfers = append(sum.startedTransfers, stats.startedTransfers...)
- sum.transferQueueSize += stats.transferQueueSize
- sum.oldDuration += stats.oldDuration
sum.oldTimeRanges = append(sum.oldTimeRanges, stats.oldTimeRanges...)
+ sum.oldDuration += stats.oldDuration
stats.average.mu.Lock()
sum.average.speed += stats.average.speed
stats.average.mu.Unlock()