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

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() idx := restic.NewHardlinkIndex()
return res.traverseTree(ctx, dst, string(filepath.Separator), *res.sn.Tree, treeVisitor{ return res.traverseTree(ctx, dst, string(filepath.Separator), *res.sn.Tree, treeVisitor{
enterDir: func(node *restic.Node, target, location string) error { enterDir: func(node *restic.Node, target, location string) error {