Improvements to deletion

This commit is contained in:
Alex Yatskov 2015-06-22 13:09:22 +09:00
parent 95288801e9
commit c4323d28dc

16
dir.go
View File

@ -114,18 +114,14 @@ func (vd *verDir) removeDir(name string) error {
} }
node := vd.dirs[name].node node := vd.dirs[name].node
ver := node.ver
if node.flags&NodeFlagNew == NodeFlagNew { if node.flags&NodeFlagNew == NodeFlagNew {
if err := os.Remove(node.rebasedPath()); err != nil { if err := os.Remove(node.rebasedPath()); err != nil {
return err return err
} }
ver = ver.parent
} }
if ver != nil { if node.parent != nil {
ver.meta.removeNode(node.path) vd.node.ver.meta.removeNode(node.path)
} }
delete(vd.dirs, name) delete(vd.dirs, name)
@ -138,18 +134,14 @@ func (vd *verDir) removeFile(name string) error {
} }
node := vd.files[name].node node := vd.files[name].node
ver := node.ver
if node.flags&NodeFlagNew == NodeFlagNew { if node.flags&NodeFlagNew == NodeFlagNew {
if err := os.Remove(node.rebasedPath()); err != nil { if err := os.Remove(node.rebasedPath()); err != nil {
return err return err
} }
ver = ver.parent
} }
if ver != nil { if node.parent != nil {
ver.meta.removeNode(node.path) vd.node.ver.meta.removeNode(node.path)
} }
delete(vd.files, name) delete(vd.files, name)