diff options
author | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-09-22 10:06:18 +0200 |
---|---|---|
committer | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-09-22 10:06:18 +0200 |
commit | f7901489d13c90c0f4d4273e93eacc990087e6b8 (patch) | |
tree | d7e0434494ca9802da8fa9e4f7fa7e9b4f0670d1 /lib/model/folders.go | |
parent | 1966f9e786dfb67543401d181a374bd7f3856f37 (diff) |
Allow to run xds-server without syncthing support.
To disable synchting support, just don't declare
"syncthing": {...} section in config.json file.
Diffstat (limited to 'lib/model/folders.go')
-rw-r--r-- | lib/model/folders.go | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/lib/model/folders.go b/lib/model/folders.go index 7c08a88..576c4a2 100644 --- a/lib/model/folders.go +++ b/lib/model/folders.go @@ -78,6 +78,8 @@ func (f *Folders) LoadConfig() error { // Don't exit on such error, just log it f.Log.Errorf(err.Error()) } + } else { + f.Log.Infof("Syncthing support is disabled.") } // Merge syncthing folders into XDS folders @@ -101,20 +103,22 @@ func (f *Folders) LoadConfig() error { // Detect ghost project // (IOW existing in xds file config and not in syncthing database) - for i, xf := range flds { - // only for syncthing project - if xf.Type != folder.TypeCloudSync { - continue - } - found := false - for _, stf := range stFlds { - if stf.ID == xf.ID { - found = true - break + if f.SThg != nil { + for i, xf := range flds { + // only for syncthing project + if xf.Type != folder.TypeCloudSync { + continue + } + found := false + for _, stf := range stFlds { + if stf.ID == xf.ID { + found = true + break + } + } + if !found { + flds[i].Status = folder.StatusErrorConfig } - } - if !found { - flds[i].Status = folder.StatusErrorConfig } } @@ -196,10 +200,13 @@ func (f *Folders) createUpdate(newF folder.FolderConfig, create bool, initial bo switch newF.Type { // SYNCTHING case folder.TypeCloudSync: - if f.SThg == nil { - return nil, fmt.Errorf("CloudSync type not supported (syncthing not initialized)") + if f.SThg != nil { + fld = f.SThg.NewFolderST(f.Conf) + } else { + f.Log.Debugf("Disable project %v (syncthing not initialized)", newF.ID) + fld = folder.NewFolderSTDisable(f.Conf) } - fld = f.SThg.NewFolderST(f.Conf) + // PATH MAP case folder.TypePathMap: fld = folder.NewFolderPathMap(f.Conf) |