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

accounting: fix race detected by the race detector

Nick Craig-Wood10270a4354c0
diff --git a/fs/accounting/stats.go b/fs/accounting/stats.go
index 7763c1497..e46f95e5c 100644
--- a/fs/accounting/stats.go
+++ b/fs/accounting/stats.go
@@ -313,7 +313,9 @@ func (s *StatsInfo) calculateTransferStats() (ts transferStats) {
// note that s.bytes already includes transferringBytesDone so
// we take it off here to avoid double counting
ts.totalBytes = s.transferQueueSize + s.bytes + transferringBytesTotal - transferringBytesDone
+ s.average.mu.Lock()
ts.speed = s.average.speed
+ s.average.mu.Unlock()
dt := s._totalDuration()
ts.transferTime = dt.Seconds()