mirror of
https://github.com/rclone/rclone.git
synced 2025-04-19 18:31:10 +08: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
626bdacd59
commit
1b47b7a6bb
@ -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…
x
Reference in New Issue
Block a user