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: fix file leaks with --vfs-cache-mode full and --buffer-size 0

Nick Craig-Woodb80d49830454
diff --git a/vfs/vfscache/downloaders/downloaders.go b/vfs/vfscache/downloaders/downloaders.go
index 190d38117..9973d0cef 100644
--- a/vfs/vfscache/downloaders/downloaders.go
+++ b/vfs/vfscache/downloaders/downloaders.go
@@ -26,6 +26,9 @@ const (
backgroundKickerInterval = 5 * time.Second
// maximum number of errors before declaring dead
maxErrorCount = 10
+ // If a downloader is within this range or --buffer-size
+ // whichever is the larger, we will reuse the downloader
+ minWindow = 1024 * 1024
)
// Item is the interface that an item to download must obey
@@ -327,6 +330,11 @@ func (dls *Downloaders) _ensureDownloader(r ranges.Range) (err error) {
r.Size = 0
}
+ // If buffer size is less than minWindow then make it that
+ if window < minWindow {
+ window = minWindow
+ }
+
var dl *downloader
// Look through downloaders to find one in range
// If there isn't one then start a new one