1
0
mirror of https://github.com/gilbertchen/duplicacy synced 2025-12-06 00:03:38 +00:00

Fixed a bug that restoring files doesn't work due to missing parent directory

The root cause was path.Dir can't handle Windows paths that use \ as the
separator.
This commit is contained in:
Gilbert Chen
2019-06-04 21:57:10 -04:00
parent 37781f9540
commit 47c4c25d8b
3 changed files with 11 additions and 1 deletions

View File

@@ -899,7 +899,8 @@ func (manager *BackupManager) Restore(top string, revision int, inPlace bool, qu
continue
}
} else {
err = os.MkdirAll(path.Dir(fullPath), 0744)
parent, _ := SplitDir(fullPath)
err = os.MkdirAll(parent, 0744)
if err != nil {
LOG_ERROR("DOWNLOAD_MKDIR", "Failed to create directory: %v", err)
}

View File

@@ -88,3 +88,7 @@ func (entry *Entry) SetAttributesToFile(fullPath string) {
func joinPath(components ...string) string {
return path.Join(components...)
}
func SplitDir(fullPath string) (dir string, file string) {
return path.Split(fullPath)
}

View File

@@ -126,3 +126,8 @@ func joinPath(components ...string) string {
}
return combinedPath
}
func SplitDir(fullPath string) (dir string, file string) {
i := strings.LastIndex(fullPath, "\\")
return fullPath[:i+1], fullPath[i+1:]
}