From ad8f8d97a48f155ba94d5646012e969845a315ab Mon Sep 17 00:00:00 2001 From: Sebastien Douheret Date: Mon, 22 May 2017 13:51:04 +0200 Subject: Allow to set Syncthing rescanInterval parameter. --- lib/common/error.go | 7 +++++-- lib/syncthing/stfolder.go | 4 ++++ lib/xdsconfig/fileconfig.go | 9 +++++---- 3 files changed, 14 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/common/error.go b/lib/common/error.go index d03c176..6873d82 100644 --- a/lib/common/error.go +++ b/lib/common/error.go @@ -1,13 +1,16 @@ package common import ( + "fmt" + "github.com/gin-gonic/gin" ) // APIError returns an uniform json formatted error -func APIError(c *gin.Context, err string) { +func APIError(c *gin.Context, format string, args ...interface{}) { + errMsg := fmt.Sprintf(format, args...) c.JSON(500, gin.H{ "status": "error", - "error": err, + "error": errMsg, }) } diff --git a/lib/syncthing/stfolder.go b/lib/syncthing/stfolder.go index 45ac60d..e7ee0ec 100644 --- a/lib/syncthing/stfolder.go +++ b/lib/syncthing/stfolder.go @@ -58,6 +58,10 @@ func (s *SyncThing) FolderChange(f xdsconfig.FolderConfig) error { RawPath: filepath.Join(s.conf.ShareRootDir, f.RelativePath), } + if s.conf.FileConf.SThgConf.RescanIntervalS > 0 { + folder.RescanIntervalS = s.conf.FileConf.SThgConf.RescanIntervalS + } + folder.Devices = append(folder.Devices, config.FolderDeviceConfiguration{ DeviceID: newDevice.DeviceID, }) diff --git a/lib/xdsconfig/fileconfig.go b/lib/xdsconfig/fileconfig.go index 4be54ff..01bd4c9 100644 --- a/lib/xdsconfig/fileconfig.go +++ b/lib/xdsconfig/fileconfig.go @@ -12,10 +12,11 @@ import ( ) type SyncThingConf struct { - BinDir string `json:"binDir"` - Home string `json:"home"` - GuiAddress string `json:"gui-address"` - GuiAPIKey string `json:"gui-apikey"` + BinDir string `json:"binDir"` + Home string `json:"home"` + GuiAddress string `json:"gui-address"` + GuiAPIKey string `json:"gui-apikey"` + RescanIntervalS int `json:"rescanIntervalS"` } type FileConfig struct { -- cgit 1.2.3-korg