1
mirror of https://github.com/rclone/rclone synced 2024-09-22 20:52:03 +02:00

mountlib: fix race condition in cache clear

This commit is contained in:
Nick Craig-Wood 2017-05-19 15:45:34 +01:00
parent e172f00e0e
commit 2cae017738

View File

@ -96,6 +96,8 @@ func (d *Dir) ForgetPath(relativePath string) {
// children first. It will not apply the function to parent
// nodes, regardless of the given path.
func (d *Dir) walk(absPath string, fun func(*Dir)) {
d.mu.Lock()
defer d.mu.Unlock()
if d.items != nil {
for _, entry := range d.items {
if dir, ok := entry.Node.(*Dir); ok {
@ -105,8 +107,6 @@ func (d *Dir) walk(absPath string, fun func(*Dir)) {
}
if d.path == absPath || absPath == "" || strings.HasPrefix(d.path, absPath+"/") {
d.mu.Lock()
defer d.mu.Unlock()
fun(d)
}
}