1
mirror of https://github.com/rclone/rclone synced 2024-11-10 08:08:35 +01:00

vfs: fix race in cache tests

This commit is contained in:
Nick Craig-Wood 2018-02-15 21:34:37 +00:00
parent b1945d0094
commit 9b800d7184

View File

@ -133,14 +133,18 @@ name="potato" isFile=true opens=1`, itemAsString(c))
// updateAtimes - not in the cache
oldItem := item
c.itemMu.Lock()
delete(c.item, "potato") // remove from cache
c.itemMu.Unlock()
err = c.updateAtimes()
require.NoError(t, err)
assert.Equal(t, `name="" isFile=false opens=1
name="potato" isFile=true opens=0`, itemAsString(c))
item = c.get("potato")
assert.Equal(t, atime, item.atime)
c.itemMu.Lock()
c.item["potato"] = oldItem // restore to cache
c.itemMu.Unlock()
// try purging with file open
c.purgeOld(10 * time.Second)