aboutsummaryrefslogtreecommitdiffstats
path: root/lib/model
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-11-06 10:50:12 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-11-06 16:00:04 +0100
commit8d3f51e52894d46a4a92a944bc09f4ceaa1abf51 (patch)
tree1d4315736ce539c8618f26838d5145a28008ba63 /lib/model
parentb1708565ee2b4d725bb98c6b015f16af3d2a097e (diff)
Fixed folder ID and label generation.
Folder ID is now a simple uuid (without sub-string of label)
Diffstat (limited to 'lib/model')
-rw-r--r--lib/model/folders.go23
1 files changed, 11 insertions, 12 deletions
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)