local: Fix creating data dirs

This commit is contained in:
Alexander Neumann
2017-09-11 21:29:37 +02:00
parent 227b01395f
commit 5bf2228596
3 changed files with 97 additions and 1 deletions

View File

@@ -57,11 +57,14 @@ func Open(cfg Config) (*Local, error) {
// if data dir exists, make sure that all subdirs also exist
datadir := be.Dirname(restic.Handle{Type: restic.DataFile})
if dirExists(datadir) {
debug.Log("datadir %v exists", datadir)
for _, d := range be.Paths() {
if _, err := filepath.Rel(datadir, d); err != nil {
if !fs.HasPathPrefix(datadir, d) {
debug.Log("%v is not subdir of datadir %v", d, datadir)
continue
}
debug.Log("MkdirAll %v", d)
err := fs.MkdirAll(d, backend.Modes.Dir)
if err != nil {
return nil, errors.Wrap(err, "MkdirAll")