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

vfs: writeback - stop the timer explicitly on transfers exceeded

Nick Craig-Woodb9ff49548301
diff --git a/vfs/vfscache/writeback.go b/vfs/vfscache/writeback.go
index 84b4efece..c0cf2ce3b 100644
--- a/vfs/vfscache/writeback.go
+++ b/vfs/vfscache/writeback.go
@@ -187,19 +187,24 @@ func (wb *writeBack) _peekItem() (wbItem *writeBackItem) {
return wb.items[0]
}
+// stop the timer which runs the expiries
+func (wb *writeBack) _stopTimer() {
+ if wb.expiry.IsZero() {
+ return
+ }
+ wb.expiry = time.Time{}
+ fs.Debugf(nil, "resetTimer STOP")
+ if wb.timer != nil {
+ wb.timer.Stop()
+ wb.timer = nil
+ }
+}
+
// reset the timer which runs the expiries
func (wb *writeBack) _resetTimer() {
wbItem := wb._peekItem()
if wbItem == nil {
- if wb.expiry.IsZero() {
- return
- }
- wb.expiry = time.Time{}
- fs.Debugf(nil, "resetTimer STOP")
- if wb.timer != nil {
- wb.timer.Stop()
- wb.timer = nil
- }
+ wb._stopTimer()
} else {
if wb.expiry.Equal(wbItem.expiry) {
return
@@ -377,6 +382,8 @@ func (wb *writeBack) processItems(ctx context.Context) {
if resetTimer {
wb._resetTimer()
+ } else {
+ wb._stopTimer()
}
}