Refactor node.go

This commit is contained in:
Florian Weingarten
2015-04-28 21:24:43 -04:00
parent c9422c3b32
commit 4bb724fac2
4 changed files with 113 additions and 175 deletions

View File

@@ -47,7 +47,7 @@ func (res *Restorer) to(dst string, dir string, treeBlob server.Blob) error {
if res.Filter == nil ||
res.Filter(filepath.Join(dir, node.Name), dstpath, node) {
err := CreateNodeAt(node, tree.Map, res.s, dstpath)
err := node.CreateAt(dstpath, tree.Map, res.s)
// Did it fail because of ENOENT?
if arrar.Check(err, func(err error) bool {
@@ -60,7 +60,7 @@ func (res *Restorer) to(dst string, dir string, treeBlob server.Blob) error {
// Create parent directories and retry
err = os.MkdirAll(filepath.Dir(dstpath), 0700)
if err == nil || err == os.ErrExist {
err = CreateNodeAt(node, tree.Map, res.s, dstpath)
err = node.CreateAt(dstpath, tree.Map, res.s)
}
}