aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-12-08 18:08:52 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-12-08 18:08:52 +0100
commit780aa41657c49e6ed01569d96dbde370006cdf92 (patch)
tree6e1dd63ac2a8ed7652b2dff816f67b244d1417e8
parentd01746b3b667a85ddd8b68eb504abcd071006357 (diff)
Support old folder type encoding (backward compatibility)
-rw-r--r--.vscode/settings.json2
-rw-r--r--lib/xdsserver/folders.go18
2 files changed, 16 insertions, 4 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json
index ac5a7b6..24aa012 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -29,6 +29,6 @@
"inotify", "Inot", "pname", "pkill", "sdkid", "CLOUDSYNC", "xdsagent",
"gdbserver", "golib", "eows", "mfolders", "IFOLDER", "flds", "dflt",
"stconfig", "reflectme", "franciscocpg", "crosssdk", "urfave", "EXEPATH",
- "conv", "Sillyf"
+ "conv", "Sillyf", "xsapiv"
]
}
diff --git a/lib/xdsserver/folders.go b/lib/xdsserver/folders.go
index 41158fb..7a45bbd 100644
--- a/lib/xdsserver/folders.go
+++ b/lib/xdsserver/folders.go
@@ -28,8 +28,8 @@ import (
"github.com/franciscocpg/reflectme"
common "github.com/iotbzh/xds-common/golib"
- "github.com/iotbzh/xds-server/lib/xsapiv1"
"github.com/iotbzh/xds-server/lib/xdsconfig"
+ "github.com/iotbzh/xds-server/lib/xsapiv1"
"github.com/syncthing/syncthing/lib/sync"
)
@@ -425,8 +425,8 @@ func (f *Folders) IsFolderInSync(id string) (bool, error) {
// Use XML format and not json to be able to save/load all fields including
// ones that are masked in json (IOW defined with `json:"-"`)
type xmlFolders struct {
- XMLName xml.Name `xml:"folders"`
- Version string `xml:"version,attr"`
+ XMLName xml.Name `xml:"folders"`
+ Version string `xml:"version,attr"`
Folders []xsapiv1.FolderConfig `xml:"folders"`
}
@@ -448,6 +448,18 @@ func foldersConfigRead(file string, folders *[]xsapiv1.FolderConfig) error {
data := xmlFolders{}
err = xml.NewDecoder(fd).Decode(&data)
if err == nil {
+ // Decode old type encoding (number) for backward compatibility
+ for i, d := range data.Folders {
+ switch d.Type {
+ case "1":
+ data.Folders[i].Type = xsapiv1.TypePathMap
+ case "2":
+ data.Folders[i].Type = xsapiv1.TypeCloudSync
+ case "3":
+ data.Folders[i].Type = xsapiv1.TypeCifsSmb
+ }
+ }
+
*folders = data.Folders
}
return err