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: use appropriate Lock func's

Fabian Möller9c90b5e77c9a
diff --git a/fs/accounting/stats.go b/fs/accounting/stats.go
index ca0f3084c..c16f46bdb 100644
--- a/fs/accounting/stats.go
+++ b/fs/accounting/stats.go
@@ -102,8 +102,8 @@ func (s *StatsInfo) Bytes(bytes int64) {
// GetBytes returns the number of bytes transferred so far
func (s *StatsInfo) GetBytes() int64 {
- s.mu.Lock()
- defer s.mu.Unlock()
+ s.mu.RLock()
+ defer s.mu.RUnlock()
return s.bytes
}
@@ -138,8 +138,8 @@ func (s *StatsInfo) Deletes(deletes int64) int64 {
// ResetCounters sets the counters (bytes, checks, errors, transfers) to 0
func (s *StatsInfo) ResetCounters() {
- s.mu.RLock()
- defer s.mu.RUnlock()
+ s.mu.Lock()
+ defer s.mu.Unlock()
s.bytes = 0
s.errors = 0
s.checks = 0
@@ -149,8 +149,8 @@ func (s *StatsInfo) ResetCounters() {
// ResetErrors sets the errors count to 0
func (s *StatsInfo) ResetErrors() {
- s.mu.RLock()
- defer s.mu.RUnlock()
+ s.mu.Lock()
+ defer s.mu.Unlock()
s.errors = 0
}