aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/folder/folder-interface.go8
-rw-r--r--lib/folder/folder-pathmap.go6
-rw-r--r--lib/folder/folder-st-disable.go6
-rw-r--r--lib/model/folders.go23
-rw-r--r--lib/syncthing/folder-st.go6
5 files changed, 31 insertions, 18 deletions
diff --git a/lib/folder/folder-interface.go b/lib/folder/folder-interface.go
index aec773d..9eb6829 100644
--- a/lib/folder/folder-interface.go
+++ b/lib/folder/folder-interface.go
@@ -60,9 +60,11 @@ type FolderConfig struct {
// PathMapConfig Path mapping specific data
type PathMapConfig struct {
- ServerPath string `json:"serverPath"`
- CheckFile string `json:"checkFile"`
- CheckContent string `json:"checkContent"`
+ ServerPath string `json:"serverPath"`
+
+ // Don't keep temporary file name (IOW we don't want to save it and reuse it)
+ CheckFile string `json:"checkFile" xml:"-"`
+ CheckContent string `json:"checkContent" xml:"-"`
}
// CloudSyncConfig CloudSync (AKA Syncthing) specific data
diff --git a/lib/folder/folder-pathmap.go b/lib/folder/folder-pathmap.go
index bc714dd..e200164 100644
--- a/lib/folder/folder-pathmap.go
+++ b/lib/folder/folder-pathmap.go
@@ -33,7 +33,11 @@ func NewFolderPathMap(gc *xdsconfig.Config) *PathMap {
// NewUID Get a UUID
func (f *PathMap) NewUID(suffix string) string {
- return uuid.NewV1().String() + "_" + suffix
+ uuid := uuid.NewV1().String()
+ if len(suffix) > 0 {
+ uuid += "_" + suffix
+ }
+ return uuid
}
// Add a new folder
diff --git a/lib/folder/folder-st-disable.go b/lib/folder/folder-st-disable.go
index f90b776..7b53ca8 100644
--- a/lib/folder/folder-st-disable.go
+++ b/lib/folder/folder-st-disable.go
@@ -25,7 +25,11 @@ func NewFolderSTDisable(gc *xdsconfig.Config) *STFolderDisable {
// NewUID Get a UUID
func (f *STFolderDisable) NewUID(suffix string) string {
- return uuid.NewV1().String() + "_" + suffix
+ uuid := uuid.NewV1().String()
+ if len(suffix) > 0 {
+ uuid += "_" + suffix
+ }
+ return uuid
}
// Add a new folder
diff --git a/lib/model/folders.go b/lib/model/folders.go
index 24ac48c..d5ea3bf 100644
--- a/lib/model/folders.go
+++ b/lib/model/folders.go
@@ -213,24 +213,23 @@ func (f *Folders) createUpdate(newF folder.FolderConfig, create bool, initial bo
return nil, fmt.Errorf("Unsupported folder type")
}
+ // Allocate a new UUID
+ if create {
+ newF.ID = fld.NewUID("")
+ }
+ if !create && newF.ID == "" {
+ return nil, fmt.Errorf("Cannot update folder with null ID")
+ }
+
// Set default value if needed
if newF.Status == "" {
newF.Status = folder.StatusDisable
}
if newF.Label == "" {
- newF.Label = filepath.Base(newF.ClientPath) + "_" + newF.ID[0:8]
- }
-
- // Allocate a new UUID
- if create {
- i := len(newF.Label)
- if i > 20 {
- i = 20
+ newF.Label = filepath.Base(newF.ClientPath)
+ if len(newF.ID) > 8 {
+ newF.Label += "_" + newF.ID[0:8]
}
- newF.ID = fld.NewUID(newF.Label[:i])
- }
- if !create && newF.ID == "" {
- return nil, fmt.Errorf("Cannot update folder with null ID")
}
// Normalize path (needed for Windows path including bashlashes)
diff --git a/lib/syncthing/folder-st.go b/lib/syncthing/folder-st.go
index 27a43e6..f25a505 100644
--- a/lib/syncthing/folder-st.go
+++ b/lib/syncthing/folder-st.go
@@ -39,7 +39,11 @@ func (f *STFolder) NewUID(suffix string) string {
if i > 15 {
i = 15
}
- return uuid.NewV1().String()[:14] + f.st.MyID[:i] + "_" + suffix
+ uuid := uuid.NewV1().String()[:14] + f.st.MyID[:i]
+ if len(suffix) > 0 {
+ uuid += "_" + suffix
+ }
+ return uuid
}
// Add a new folder