From 47d08ac1f12fefe03dd9eb6fd9bdb236364d5587 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 18 Aug 2020 17:31:39 +0100 Subject: [PATCH] vfs: recommend --vfs-cache-modes writes on backends which can't stream --- vfs/vfs.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vfs/vfs.go b/vfs/vfs.go index 58d725648..dd54bdb9a 100644 --- a/vfs/vfs.go +++ b/vfs/vfs.go @@ -216,7 +216,8 @@ func New(f fs.Fs, opt *vfscommon.Options) *VFS { vfs.root = newDir(vfs, f, nil, fsDir) // Start polling function - if do := vfs.f.Features().ChangeNotify; do != nil { + features := vfs.f.Features() + if do := features.ChangeNotify; do != nil { vfs.pollChan = make(chan time.Duration) do(context.TODO(), vfs.root.changeNotify, vfs.pollChan) vfs.pollChan <- vfs.Opt.PollInterval @@ -224,6 +225,11 @@ func New(f fs.Fs, opt *vfscommon.Options) *VFS { fs.Infof(f, "poll-interval is not supported by this remote") } + // Warn if can't stream + if !vfs.Opt.ReadOnly && vfs.Opt.CacheMode < vfscommon.CacheModeWrites && features.PutStream == nil { + 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