Don't consider a pre-existing directory in the restore path to be a failure

* When a directory already exists, CreateDirAt returns an error stating so
  * This means that the restoreMetadata step is skipped, so for directories which already exist no file permissions, owners, groups, etc will be restored on them
* Not returning the error if it's a "directory exists" error means the metadata will get restored
  * It also removes the superfluous "error for ...: mkdir ...: file exists" messages
* This makes the behaviour of directories consistent with that of files (which always have their content & metadata restored, regardless of whether they existed or not)
This commit is contained in:
Seb Patane 2016-11-14 17:53:09 +10:00
parent 190673b24a
commit 33b6a7381b

View file

@ -184,7 +184,7 @@ func (node Node) RestoreTimestamps(path string) error {
func (node Node) createDirAt(path string) error {
err := fs.Mkdir(path, node.Mode)
if err != nil {
if err != nil && !os.IsExist(err) {
return errors.Wrap(err, "Mkdir")
}