restore: Make sure target directory exists

This commit is contained in:
Alexander Neumann 2018-07-15 16:02:04 +02:00
parent 9acc9243ba
commit 92421ec47f
1 changed files with 6 additions and 0 deletions

View File

@ -197,6 +197,12 @@ func (res *Restorer) RestoreTo(ctx context.Context, dst string) error {
}
}
// make sure the target directory exists
err = fs.MkdirAll(dst, 0777) // umask takes care of dir permissions
if err != nil {
return errors.Wrap(err, "MkdirAll")
}
idx := restic.NewHardlinkIndex()
return res.traverseTree(ctx, dst, string(filepath.Separator), *res.sn.Tree, treeVisitor{
enterDir: func(node *restic.Node, target, location string) error {