From fc798d800ceef287387a6a31be55155384904d46 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sun, 14 May 2023 11:46:06 +0100 Subject: [PATCH] vfs: fix backends being Shutdown too early when startup takes a long time Before this change if the VFS took more than 5 to initialise (which can happen if there is a lot of files or a lot of files which need uploading) the backend was dropped out of the cache before the VFS was fully created. This was noticeable in the dropbox backend where the batcher Shutdown too soon and prevented further uploads. This fixes the problem by Pinning backends before the VFS cache is created. https://forum.rclone.org/t/if-more-than-251-elements-in-the-que-to-upload-fails-with-batcher-is-shutting-down/38076/2 --- vfs/vfs.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vfs/vfs.go b/vfs/vfs.go index 00faadf2e..dc15f2586 100644 --- a/vfs/vfs.go +++ b/vfs/vfs.go @@ -227,13 +227,14 @@ func New(f fs.Fs, opt *vfscommon.Options) *VFS { fs.Logf(f, "--vfs-cache-mode writes or full is recommended for this remote as it can't stream") } - vfs.SetCacheMode(vfs.Opt.CacheMode) - // Pin the Fs into the cache so that when we use cache.NewFs // with the same remote string we get this one. The Pin is // removed when the vfs is finalized cache.PinUntilFinalized(f, vfs) + // This can take some time so do it after the Pin + vfs.SetCacheMode(vfs.Opt.CacheMode) + return vfs }