summaryrefslogtreecommitdiffstats
path: root/lib/xdsconfig/folderconfig.go
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-05-16 22:51:32 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-05-17 14:04:32 +0200
commitc07adb807c41a1545a9a0f5bbf40080d86946538 (patch)
tree21e00efbcd03360416698663a1ea89536717ae86 /lib/xdsconfig/folderconfig.go
parent8983eebdbe74489d62eae4097580fc430d75bd07 (diff)
Auto start Syncthing and Syncthing-inotify.
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'lib/xdsconfig/folderconfig.go')
-rw-r--r--lib/xdsconfig/folderconfig.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/xdsconfig/folderconfig.go b/lib/xdsconfig/folderconfig.go
index f22e76f..e32f46a 100644
--- a/lib/xdsconfig/folderconfig.go
+++ b/lib/xdsconfig/folderconfig.go
@@ -30,8 +30,8 @@ type FolderConfig struct {
BuilderSThgID string `json:"builderSThgID"`
Status string `json:"status"`
- // Private fields
- rootPath string
+ // Not exported fields
+ RootPath string `json:"-"`
}
// NewFolderConfig creates a new folder object
@@ -43,7 +43,7 @@ func NewFolderConfig(id, label, rootDir, path string) FolderConfig {
Type: FolderTypeCloudSync,
SyncThingID: "",
Status: FolderStatusDisable,
- rootPath: rootDir,
+ RootPath: rootDir,
}
}
@@ -53,30 +53,30 @@ func (c *FolderConfig) GetFullPath(dir string) string {
dir = ""
}
if filepath.IsAbs(dir) {
- return filepath.Join(c.rootPath, dir)
+ return filepath.Join(c.RootPath, dir)
}
- return filepath.Join(c.rootPath, c.RelativePath, dir)
+ return filepath.Join(c.RootPath, c.RelativePath, dir)
}
-// FolderVerify is called to verify that a configuration is valid
-func FolderVerify(fCfg FolderConfig) error {
+// Verify is called to verify that a configuration is valid
+func (c *FolderConfig) Verify() error {
var err error
- if fCfg.Type != FolderTypeCloudSync {
+ if c.Type != FolderTypeCloudSync {
err = fmt.Errorf("Unsupported folder type")
}
- if fCfg.SyncThingID == "" {
+ if c.SyncThingID == "" {
err = fmt.Errorf("device id not set (SyncThingID field)")
}
- if fCfg.rootPath == "" {
- err = fmt.Errorf("rootPath must not be empty")
+ if c.RootPath == "" {
+ err = fmt.Errorf("RootPath must not be empty")
}
if err != nil {
- fCfg.Status = FolderStatusErrorConfig
- log.Printf("ERROR FolderVerify: %v\n", err)
+ c.Status = FolderStatusErrorConfig
+ log.Printf("ERROR Verify: %v\n", err)
}
return err