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

zoho: fix flaky folder list limiter test under concurrent listings

Nick Craig-Wood2b099f266727
diff --git a/backend/zoho/zoho.go b/backend/zoho/zoho.go
index dc82965d0..28e0d6e13 100644
--- a/backend/zoho/zoho.go
+++ b/backend/zoho/zoho.go
@@ -447,6 +447,12 @@ const folderListSafetyMargin = 500 * time.Millisecond
func (l *folderWindowLimiter) reserve(now time.Time) time.Time {
l.mu.Lock()
defer l.mu.Unlock()
+ // Never let a grant move backwards, even if concurrent callers observe
+ // time.Now() out of order: the sliding safety log below indexes grants as
+ // an ordered history, so out-of-order grant times would corrupt the cap.
+ if now.Before(l.lastGrant) {
+ now = l.lastGrant
+ }
if l.windowStart.IsZero() {
l.windowStart = now
}