X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=lib%2Fxdsserver%2Ffolders.go;h=7a45bbd20607a4db60d2aedc8183425f39f8e275;hb=780aa41657c49e6ed01569d96dbde370006cdf92;hp=e36f84c41b5b7764f5f0236799ec737cf6eadd5e;hpb=2f7828d01f4c4ca2909f95f098627cd5475ed225;p=src%2Fxds%2Fxds-server.git diff --git a/lib/xdsserver/folders.go b/lib/xdsserver/folders.go index e36f84c..7a45bbd 100644 --- a/lib/xdsserver/folders.go +++ b/lib/xdsserver/folders.go @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2017 "IoT.bzh" + * Author Sebastien Douheret + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package xdsserver import ( @@ -11,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" ) @@ -408,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"` } @@ -431,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