"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
vfs: fix vfs cache writeback timer not being stopped when --transfers reached
Nick Craig-Woodc851d4dec5b3
diff --git a/vfs/vfscache/writeback/writeback.go b/vfs/vfscache/writeback/writeback.goindex 255154171..76acbb446 100644--- a/vfs/vfscache/writeback/writeback.go+++ b/vfs/vfscache/writeback/writeback.go@@ -433,13 +433,18 @@ func (wb *WriteBack) processItems(ctx context.Context) {}resetTimer := true- for wbItem := wb._peekItem(); wbItem != nil && time.Until(wbItem.expiry) <= 0; wbItem = wb._peekItem() {- // If reached transfer limit don't restart the timer+ for wbItem := wb._peekItem(); wbItem != nil; wbItem = wb._peekItem() {+ // If reached transfer limit stop the timer - it will be+ // restarted when an upload finishesif wb.uploads >= fs.GetConfig(wb.ctx).Transfers {fs.Debugf(wbItem.name, "vfs cache: delaying writeback as --transfers exceeded")resetTimer = falsebreak}+ // Stop if the next item hasn't expired yet+ if time.Until(wbItem.expiry) > 0 {+ break+ }// Pop the item, mark as uploading and start the uploaderwbItem = wb._popItem()//fs.Debugf(wbItem.name, "uploading = true %p item %p", wbItem, wbItem.item)diff --git a/vfs/vfscache/writeback/writeback_test.go b/vfs/vfscache/writeback/writeback_test.goindex 87c067627..8122ae2da 100644--- a/vfs/vfscache/writeback/writeback_test.go+++ b/vfs/vfscache/writeback/writeback_test.go@@ -601,10 +601,10 @@ func TestWriteBackMaxQueue(t *testing.T) {// put toTransfer things in the queuepis := []*putItem{}- for range toTransfer {+ for i := range toTransfer {pi := newPutItem(t)pis = append(pis, pi)- wb.Add(0, fmt.Sprintf("number%d", 1), 10, true, pi.put)+ wb.Add(0, fmt.Sprintf("number%d", i), 10, true, pi.put)}inProgress, queued := wb.Stats()