diff --git a/dir.go b/dir.go index 35da465..0dc34e2 100644 --- a/dir.go +++ b/dir.go @@ -116,9 +116,6 @@ func (vd *verDir) createFile(name string, flags fuse.OpenFlags, mode os.FileMode } func (vd *verDir) removeDir(name string) error { - vd.mutex.Lock() - defer vd.mutex.Unlock() - if err := vd.version(); err != nil { return err } @@ -132,14 +129,14 @@ func (vd *verDir) removeDir(name string) error { vd.node.ver.meta.removeNode(node.path) } + vd.mutex.Lock() delete(vd.dirs, name) + vd.mutex.Unlock() + return nil } func (vd *verDir) removeFile(name string) error { - vd.mutex.Lock() - defer vd.mutex.Unlock() - if err := vd.version(); err != nil { return err } @@ -153,7 +150,10 @@ func (vd *verDir) removeFile(name string) error { vd.node.ver.meta.removeNode(node.path) } + vd.mutex.Lock() delete(vd.files, name) + vd.mutex.Unlock() + return nil }