all: Fix versioning path handling (#7407)

This commit is contained in:
Simon Frei
2021-02-26 12:04:05 +01:00
committed by GitHub
parent a69afc9eeb
commit fff8805ff6
13 changed files with 158 additions and 72 deletions
+10 -3
View File
@@ -11,14 +11,17 @@ import (
"encoding/xml"
"sort"
"github.com/syncthing/syncthing/lib/fs"
"github.com/syncthing/syncthing/lib/util"
)
// internalVersioningConfiguration is used in XML serialization
type internalVersioningConfiguration struct {
Type string `xml:"type,attr,omitempty"`
Params []internalParam `xml:"param"`
CleanupIntervalS int `xml:"cleanupIntervalS" default:"3600"`
Type string `xml:"type,attr,omitempty"`
Params []internalParam `xml:"param"`
CleanupIntervalS int `xml:"cleanupIntervalS" default:"3600"`
FSPath string `xml:"fsPath"`
FSType fs.FilesystemType `xml:"fsType"`
}
type internalParam struct {
@@ -64,6 +67,8 @@ func (c *VersioningConfiguration) toInternal() internalVersioningConfiguration {
var tmp internalVersioningConfiguration
tmp.Type = c.Type
tmp.CleanupIntervalS = c.CleanupIntervalS
tmp.FSPath = c.FSPath
tmp.FSType = c.FSType
for k, v := range c.Params {
tmp.Params = append(tmp.Params, internalParam{k, v})
}
@@ -76,6 +81,8 @@ func (c *VersioningConfiguration) toInternal() internalVersioningConfiguration {
func (c *VersioningConfiguration) fromInternal(intCfg internalVersioningConfiguration) {
c.Type = intCfg.Type
c.CleanupIntervalS = intCfg.CleanupIntervalS
c.FSPath = intCfg.FSPath
c.FSType = intCfg.FSType
c.Params = make(map[string]string, len(intCfg.Params))
for _, p := range intCfg.Params {
c.Params[p.Key] = p.Val