Make CreateAtNodeAt() independend from Tree
This commit is contained in:
parent
9101044941
commit
79e065596f
2 changed files with 4 additions and 4 deletions
|
@ -47,7 +47,7 @@ func (res *Restorer) to(dst string, dir string, treeBlob Blob) error {
|
||||||
|
|
||||||
if res.Filter == nil ||
|
if res.Filter == nil ||
|
||||||
res.Filter(filepath.Join(res.sn.Dir, dir, node.Name), dstpath, node) {
|
res.Filter(filepath.Join(res.sn.Dir, dir, node.Name), dstpath, node) {
|
||||||
err := tree.CreateNodeAt(node, res.s, dstpath)
|
err := CreateNodeAt(node, tree.Map, res.s, dstpath)
|
||||||
|
|
||||||
// Did it fail because of ENOENT?
|
// Did it fail because of ENOENT?
|
||||||
if arrar.Check(err, func(err error) bool {
|
if arrar.Check(err, func(err error) bool {
|
||||||
|
@ -60,7 +60,7 @@ func (res *Restorer) to(dst string, dir string, treeBlob Blob) error {
|
||||||
// Create parent directories and retry
|
// Create parent directories and retry
|
||||||
err = os.MkdirAll(filepath.Dir(dstpath), 0700)
|
err = os.MkdirAll(filepath.Dir(dstpath), 0700)
|
||||||
if err == nil || err == os.ErrExist {
|
if err == nil || err == os.ErrExist {
|
||||||
err = tree.CreateNodeAt(node, res.s, dstpath)
|
err = CreateNodeAt(node, tree.Map, res.s, dstpath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
tree.go
4
tree.go
|
@ -383,7 +383,7 @@ func NodeFromFileInfo(path string, fi os.FileInfo) (*Node, error) {
|
||||||
return node, err
|
return node, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t Tree) CreateNodeAt(node *Node, s Server, path string) error {
|
func CreateNodeAt(node *Node, m *Map, s Server, path string) error {
|
||||||
switch node.Type {
|
switch node.Type {
|
||||||
case "dir":
|
case "dir":
|
||||||
err := os.Mkdir(path, node.Mode)
|
err := os.Mkdir(path, node.Mode)
|
||||||
|
@ -413,7 +413,7 @@ func (t Tree) CreateNodeAt(node *Node, s Server, path string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, blobid := range node.Content {
|
for _, blobid := range node.Content {
|
||||||
blob, err := t.Map.FindID(blobid)
|
blob, err := m.FindID(blobid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return arrar.Annotate(err, "Find Blob")
|
return arrar.Annotate(err, "Find Blob")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue