Test if a config file on open

This commit is contained in:
Alexander Neumann
2017-04-19 18:56:01 +02:00
parent 90ba606633
commit d0db1bf9b3
3 changed files with 12 additions and 16 deletions
+10
View File
@@ -402,6 +402,16 @@ func open(s string, opts options.Options) (restic.Backend, error) {
return nil, errors.Fatalf("unable to open repo at %v: %v", s, err)
}
// check if config is there
fi, err := be.Stat(restic.Handle{Type: restic.ConfigFile})
if err != nil {
return nil, errors.Fatalf("unable to open config file: %v\nIs there a repository at the following location?\n%v", err, s)
}
if fi.Size == 0 {
return nil, errors.New("config file has zero size, invalid repository?")
}
return be, nil
}