From 285332c351777b74abca638b8b2a2cde3c68edc6 Mon Sep 17 00:00:00 2001 From: Sebastien Douheret Date: Sat, 16 Dec 2017 00:10:14 +0100 Subject: Fixed and improved events management. Signed-off-by: Sebastien Douheret --- lib/syncthing/stfolder.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/syncthing/stfolder.go') diff --git a/lib/syncthing/stfolder.go b/lib/syncthing/stfolder.go index d67b164..1dcbfe1 100644 --- a/lib/syncthing/stfolder.go +++ b/lib/syncthing/stfolder.go @@ -70,6 +70,12 @@ func (s *SyncThing) FolderLoadFromStConfig(f *[]xsapiv1.FolderConfig) error { // FolderChange is called when configuration has changed func (s *SyncThing) FolderChange(f xsapiv1.FolderConfig) (string, error) { + var label, id string + + if id = f.ID; id == "" { + s.log.Errorln("Try to create Syncthing folder with null ID: %v", f) + return "", fmt.Errorf("Cannot create Syncthing folder (ID must be set") + } // Get current config stCfg, err := s.ConfigGet() @@ -104,13 +110,9 @@ func (s *SyncThing) FolderChange(f xsapiv1.FolderConfig) (string, error) { } // Add or update Folder settings - var label, id string if label = f.Label; label == "" { label = strings.Split(id, "/")[0] } - if id = f.ID; id == "" { - id = stClientID[0:15] + "_" + label - } folder := stconfig.FolderConfiguration{ ID: id, -- cgit 1.2.3-korg