1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-06 00:03:32 +00:00

vfs: disable cache cleaner if --vfs-cache-poll-interval=0

And use this to disable the cleaner in the cache tests to make them
more reliable
This commit is contained in:
Nick Craig-Wood
2018-02-16 14:12:46 +00:00
parent 70b4842823
commit 442334ba61
2 changed files with 9 additions and 2 deletions

View File

@@ -387,6 +387,10 @@ func (c *cache) clean() {
//
// doesn't return until context is cancelled
func (c *cache) cleaner(ctx context.Context) {
if c.opt.CachePollInterval <= 0 {
fs.Debugf(nil, "Cache cleaning thread disabled because poll interval <= 0")
return
}
// Start cleaning the cache immediately
c.clean()
// Then every interval specified

View File

@@ -63,9 +63,12 @@ func TestCacheNew(t *testing.T) {
defer r.Finalise()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
c, err := newCache(ctx, r.Fremote, &DefaultOpt)
cancel() // kill the background cache cleaning as it interferes with the tests
// Disable the cache cleaner as it interferes with these tests
opt := DefaultOpt
opt.CachePollInterval = 0
c, err := newCache(ctx, r.Fremote, &opt)
require.NoError(t, err)
assert.Contains(t, c.root, "vfs")