mirror of
https://github.com/octoleo/restic.git
synced 2024-11-25 14:17:42 +00:00
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,14 +91,19 @@ func (res *Restorer) restoreTo(ctx context.Context, target, location string, tre
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if selectedForRestore {
|
if selectedForRestore {
|
||||||
// Restore directory timestamp at the end. If we would do it earlier, restoring files within
|
err = res.restoreNodeTo(ctx, node, nodeTarget, nodeLocation, idx)
|
||||||
// the directory would overwrite the timestamp of the directory they are in.
|
if err != nil {
|
||||||
err = node.RestoreTimestamps(nodeTarget)
|
return err
|
||||||
if err != nil {
|
}
|
||||||
return err
|
|
||||||
}
|
// 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.
|
||||||
|
err = node.RestoreTimestamps(nodeTarget)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
Block a user