mirror of
https://github.com/rclone/rclone.git
synced 2025-01-30 02:00:22 +01:00
vfs: fix race detected by race detector
This race would only happen when --dir-cache-time was very small. This was noticed in the VFS tests when --dir-cache-time was 100 mS so is unlikely to affect normal users.
This commit is contained in:
parent
4a81f12c26
commit
2c72842c10
@ -66,7 +66,10 @@ func newDir(vfs *VFS, f fs.Fs, parent *Dir, fsDir fs.Directory) *Dir {
|
||||
inode: newInode(),
|
||||
items: make(map[string]Node),
|
||||
}
|
||||
d.cleanupTimer = time.AfterFunc(time.Duration(vfs.Opt.DirCacheTime*2), d.cacheCleanup)
|
||||
// Set timer up like this to avoid race of d.cacheCleanup being called
|
||||
// before d.cleanupTimer is assigned to
|
||||
d.cleanupTimer = time.AfterFunc(time.Hour, d.cacheCleanup)
|
||||
d.cleanupTimer.Reset(time.Duration(vfs.Opt.DirCacheTime * 2))
|
||||
return d
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user