all: Fix versioning path handling (#7407)
This commit is contained in:
@@ -41,8 +41,6 @@ func newStaggered(cfg config.FolderConfiguration) Versioner {
|
||||
maxAge = 31536000 // Default: ~1 year
|
||||
}
|
||||
|
||||
// Backwards compatibility
|
||||
params["fsPath"] = params["versionsPath"]
|
||||
versionsFs := versionerFsFromFolderCfg(cfg)
|
||||
|
||||
s := &staggered{
|
||||
|
||||
@@ -145,10 +145,8 @@ func TestCreateVersionPath(t *testing.T) {
|
||||
ID: "default",
|
||||
Path: tmpDir,
|
||||
Versioning: config.VersioningConfiguration{
|
||||
Type: "staggered",
|
||||
Params: map[string]string{
|
||||
"versionsPath": versionsDir,
|
||||
},
|
||||
Type: "staggered",
|
||||
FSPath: versionsDir,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -33,10 +33,8 @@ func TestTrashcanArchiveRestoreSwitcharoo(t *testing.T) {
|
||||
FilesystemType: fs.FilesystemTypeBasic,
|
||||
Path: tmpDir1,
|
||||
Versioning: config.VersioningConfiguration{
|
||||
Params: map[string]string{
|
||||
"fsType": "basic",
|
||||
"fsPath": tmpDir2,
|
||||
},
|
||||
FSType: fs.FilesystemTypeBasic,
|
||||
FSPath: tmpDir2,
|
||||
},
|
||||
}
|
||||
folderFs := cfg.Filesystem()
|
||||
@@ -101,6 +99,7 @@ func TestTrashcanArchiveRestoreSwitcharoo(t *testing.T) {
|
||||
}
|
||||
|
||||
func readFile(t *testing.T, filesystem fs.Filesystem, name string) string {
|
||||
t.Helper()
|
||||
fd, err := filesystem.Open(name)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
+4
-12
@@ -256,23 +256,15 @@ func restoreFile(method fs.CopyRangeMethod, src, dst fs.Filesystem, filePath str
|
||||
}
|
||||
|
||||
func versionerFsFromFolderCfg(cfg config.FolderConfiguration) (versionsFs fs.Filesystem) {
|
||||
params := cfg.Versioning.Params
|
||||
folderFs := cfg.Filesystem()
|
||||
if params["fsType"] == "" && params["fsPath"] == "" {
|
||||
if cfg.Versioning.FSPath == "" {
|
||||
versionsFs = fs.NewFilesystem(folderFs.Type(), filepath.Join(folderFs.URI(), ".stversions"))
|
||||
|
||||
} else if params["fsType"] == "" {
|
||||
uri := params["fsPath"]
|
||||
} 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
|
||||
// how to check if it's absolute or relative.
|
||||
if folderFs.Type() == fs.FilesystemTypeBasic && !filepath.IsAbs(params["fsPath"]) {
|
||||
uri = filepath.Join(folderFs.URI(), params["fsPath"])
|
||||
}
|
||||
versionsFs = fs.NewFilesystem(folderFs.Type(), uri)
|
||||
versionsFs = fs.NewFilesystem(cfg.Versioning.FSType, filepath.Join(folderFs.URI(), cfg.Versioning.FSPath))
|
||||
} else {
|
||||
var fsType fs.FilesystemType
|
||||
_ = fsType.UnmarshalText([]byte(params["fsType"]))
|
||||
versionsFs = fs.NewFilesystem(fsType, params["fsPath"])
|
||||
versionsFs = fs.NewFilesystem(cfg.Versioning.FSType, cfg.Versioning.FSPath)
|
||||
}
|
||||
l.Debugf("%s (%s) folder using %s (%s) versioner dir", folderFs.URI(), folderFs.Type(), versionsFs.URI(), versionsFs.Type())
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user