mirror of https://github.com/restic/restic.git
parent
aab414b368
commit
b8620429e2
|
@ -79,13 +79,6 @@ func (res *Restorer) restoreTo(ctx context.Context, target, location string, tre
|
||||||
selectedForRestore, childMayBeSelected := res.SelectFilter(nodeLocation, nodeTarget, node)
|
selectedForRestore, childMayBeSelected := res.SelectFilter(nodeLocation, nodeTarget, node)
|
||||||
debug.Log("SelectFilter returned %v %v", selectedForRestore, childMayBeSelected)
|
debug.Log("SelectFilter returned %v %v", selectedForRestore, childMayBeSelected)
|
||||||
|
|
||||||
if selectedForRestore {
|
|
||||||
err = res.restoreNodeTo(ctx, node, nodeTarget, nodeLocation, idx)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if node.Type == "dir" && childMayBeSelected {
|
if node.Type == "dir" && childMayBeSelected {
|
||||||
if node.Subtree == nil {
|
if node.Subtree == nil {
|
||||||
return errors.Errorf("Dir without subtree in tree %v", treeID.Str())
|
return errors.Errorf("Dir without subtree in tree %v", treeID.Str())
|
||||||
|
@ -98,8 +91,14 @@ func (res *Restorer) restoreTo(ctx context.Context, target, location string, tre
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if selectedForRestore {
|
if selectedForRestore {
|
||||||
|
err = res.restoreNodeTo(ctx, node, nodeTarget, nodeLocation, idx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Restore directory timestamp at the end. If we would do it earlier, restoring files within
|
// Restore directory timestamp at the end. If we would do it earlier, restoring files within
|
||||||
// the directory would overwrite the timestamp of the directory they are in.
|
// the directory would overwrite the timestamp of the directory they are in.
|
||||||
err = node.RestoreTimestamps(nodeTarget)
|
err = node.RestoreTimestamps(nodeTarget)
|
||||||
|
@ -108,7 +107,6 @@ func (res *Restorer) restoreTo(ctx context.Context, target, location string, tre
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,6 +178,19 @@ func TestRestorer(t *testing.T) {
|
||||||
Nodes: map[string]Node{
|
Nodes: map[string]Node{
|
||||||
"dir": Dir{
|
"dir": Dir{
|
||||||
Mode: 0444,
|
Mode: 0444,
|
||||||
|
},
|
||||||
|
"file": File{"top-level file"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Files: map[string]string{
|
||||||
|
"file": "top-level file",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Snapshot: Snapshot{
|
||||||
|
Nodes: map[string]Node{
|
||||||
|
"dir": Dir{
|
||||||
|
Mode: 0555,
|
||||||
Nodes: map[string]Node{
|
Nodes: map[string]Node{
|
||||||
"file": File{"file in dir"},
|
"file": File{"file in dir"},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue