lib/config: Retain slash at end of path after expanding ~ (fixes #2782)

The various path cleaning operations done in in cleanedPath() removes
it, so we make sure it's added again at the end. This makes adding the
slash in prepare() unnecessary, but keep it anyway for display purposes
(people looking at the config).

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3342
This commit is contained in:
Jakob Borg
2016-06-26 10:17:20 +00:00
committed by Audrius Butkevicius
parent a2dcffcca2
commit b0d03d1f1c
2 changed files with 55 additions and 0 deletions

View File

@@ -168,6 +168,12 @@ func (f *FolderConfiguration) cleanedPath() string {
return `\\?\` + cleaned
}
// If we're not on Windows, we want the path to end with a slash to
// penetrate symlinks. On Windows, paths must not end with a slash.
if runtime.GOOS != "windows" && cleaned[len(cleaned)-1] != filepath.Separator {
cleaned = cleaned + string(filepath.Separator)
}
return cleaned
}