mirror of
https://github.com/octoleo/restic.git
synced 2024-11-22 12:55:18 +00:00
Make CreateAtNodeAt() independend from Tree
This commit is contained in:
parent
9101044941
commit
79e065596f
@ -47,7 +47,7 @@ func (res *Restorer) to(dst string, dir string, treeBlob Blob) error {
|
||||
|
||||
if res.Filter == nil ||
|
||||
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?
|
||||
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
|
||||
err = os.MkdirAll(filepath.Dir(dstpath), 0700)
|
||||
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
|
||||
}
|
||||
|
||||
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 {
|
||||
case "dir":
|
||||
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 {
|
||||
blob, err := t.Map.FindID(blobid)
|
||||
blob, err := m.FindID(blobid)
|
||||
if err != nil {
|
||||
return arrar.Annotate(err, "Find Blob")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user