### Purpose Fix #9241 by expanding tildes in version paths. When creating the versioner file system, first try to expand any leading tildes to the user's home directory before handling relative paths. This makes a version path `"~/p"` expand to `"$HOME/p"` instead of `"/folder/~/p"`. ### Testing Added a test to lib/versioner that exercises this code path. Also manually tested with local syncthing instances.
This commit is contained in:
+13
-3
@@ -262,10 +262,20 @@ func versionerFsFromFolderCfg(cfg config.FolderConfiguration) (versionsFs fs.Fil
|
||||
folderFs := cfg.Filesystem(nil)
|
||||
if cfg.Versioning.FSPath == "" {
|
||||
versionsFs = fs.NewFilesystem(folderFs.Type(), filepath.Join(folderFs.URI(), DefaultPath))
|
||||
} else if cfg.Versioning.FSType == fs.FilesystemTypeBasic && !filepath.IsAbs(cfg.Versioning.FSPath) {
|
||||
// We only know how to deal with relative folders for basic filesystems, as that's the only one we know
|
||||
} else if cfg.Versioning.FSType == fs.FilesystemTypeBasic {
|
||||
// Expand any leading tildes for basic filesystems,
|
||||
// before checking for absolute paths.
|
||||
path, err := fs.ExpandTilde(cfg.Versioning.FSPath)
|
||||
if err != nil {
|
||||
path = cfg.Versioning.FSPath
|
||||
}
|
||||
// We only know how to deal with relative folders for
|
||||
// basic filesystems, as that's the only one we know
|
||||
// how to check if it's absolute or relative.
|
||||
versionsFs = fs.NewFilesystem(cfg.Versioning.FSType, filepath.Join(folderFs.URI(), cfg.Versioning.FSPath))
|
||||
if !filepath.IsAbs(path) {
|
||||
path = filepath.Join(folderFs.URI(), path)
|
||||
}
|
||||
versionsFs = fs.NewFilesystem(cfg.Versioning.FSType, path)
|
||||
} else {
|
||||
versionsFs = fs.NewFilesystem(cfg.Versioning.FSType, cfg.Versioning.FSPath)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user