2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-22 21:05:10 +00:00

Make CreateAtNodeAt() independend from Tree

This commit is contained in:
Alexander Neumann 2015-02-03 21:04:51 +01:00
parent 9101044941
commit 79e065596f
2 changed files with 4 additions and 4 deletions

View File

@ -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)
} }
} }

View File

@ -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")
} }