Code Review
/
src
/
xds
/
xds-server.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
review
|
tree
raw
|
patch
|
inline
| side by side (parent:
fbbcd6c
)
Allow to set Syncthing rescanInterval parameter.
author
Sebastien Douheret
<sebastien.douheret@iot.bzh>
Mon, 22 May 2017 11:51:04 +0000
(13:51 +0200)
committer
Sebastien Douheret
<sebastien.douheret@iot.bzh>
Mon, 22 May 2017 11:51:04 +0000
(13:51 +0200)
.vscode/settings.json
patch
|
blob
|
history
lib/common/error.go
patch
|
blob
|
history
lib/syncthing/stfolder.go
patch
|
blob
|
history
lib/xdsconfig/fileconfig.go
patch
|
blob
|
history
webapp/src/app/common/syncthing.service.ts
patch
|
blob
|
history
diff --git
a/.vscode/settings.json
b/.vscode/settings.json
index
8274151
..
99360a9
100644
(file)
--- a/
.vscode/settings.json
+++ b/
.vscode/settings.json
@@
-18,6
+18,6
@@
"apiv", "gonic", "devel", "csrffound", "Syncthing", "STID",
"ISTCONFIG", "socketio", "ldflags", "SThg", "Intf", "dismissible",
"rpath", "WSID", "sess", "IXDS", "xdsconfig", "xdsserver", "mfolder",
"apiv", "gonic", "devel", "csrffound", "Syncthing", "STID",
"ISTCONFIG", "socketio", "ldflags", "SThg", "Intf", "dismissible",
"rpath", "WSID", "sess", "IXDS", "xdsconfig", "xdsserver", "mfolder",
- "inotify", "Inot", "pname", "pkill", "sdkid", "CLOUDSYNC"
+ "inotify", "Inot", "pname", "pkill", "sdkid", "CLOUDSYNC"
, "xdsagent"
]
}
\ No newline at end of file
]
}
\ No newline at end of file
diff --git
a/lib/common/error.go
b/lib/common/error.go
index
d03c176
..
6873d82
100644
(file)
--- a/
lib/common/error.go
+++ b/
lib/common/error.go
@@
-1,13
+1,16
@@
package common
import (
package common
import (
+ "fmt"
+
"github.com/gin-gonic/gin"
)
// APIError returns an uniform json formatted error
"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",
c.JSON(500, gin.H{
"status": "error",
- "error": err,
+ "error": err
Msg
,
})
}
})
}
diff --git
a/lib/syncthing/stfolder.go
b/lib/syncthing/stfolder.go
index
45ac60d
..
e7ee0ec
100644
(file)
--- 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),
}
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,
})
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
(file)
--- a/
lib/xdsconfig/fileconfig.go
+++ b/
lib/xdsconfig/fileconfig.go
@@
-12,10
+12,11
@@
import (
)
type SyncThingConf struct {
)
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 {
}
type FileConfig struct {
diff --git
a/webapp/src/app/common/syncthing.service.ts
b/webapp/src/app/common/syncthing.service.ts
index
28b19a9
..
0e8c51c
100644
(file)
--- a/
webapp/src/app/common/syncthing.service.ts
+++ b/
webapp/src/app/common/syncthing.service.ts
@@
-1,5
+1,6
@@
import { Injectable } from '@angular/core';
import { Http, Headers, RequestOptionsArgs, Response } from '@angular/http';
import { Injectable } from '@angular/core';
import { Http, Headers, RequestOptionsArgs, Response } from '@angular/http';
+import { CookieService } from 'ngx-cookie';
import { Location } from '@angular/common';
import { Observable } from 'rxjs/Observable';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { Location } from '@angular/common';
import { Observable } from 'rxjs/Observable';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
@@
-105,6
+106,7
@@
interface ISTConfiguration {
// Default settings
const DEFAULT_GUI_PORT = 8384;
const DEFAULT_GUI_API_KEY = "1234abcezam";
// Default settings
const DEFAULT_GUI_PORT = 8384;
const DEFAULT_GUI_API_KEY = "1234abcezam";
+const DEFAULT_RESCAN_INTERV = 0; // 0: use syncthing-inotify to detect changes
@Injectable()
@Injectable()
@@
-127,7
+129,7
@@
export class SyncthingService {
};
private statusSubject = <BehaviorSubject<ISyncThingStatus>>new BehaviorSubject(this._status);
};
private statusSubject = <BehaviorSubject<ISyncThingStatus>>new BehaviorSubject(this._status);
- constructor(private http: Http, private _window: Window) {
+ constructor(private http: Http, private _window: Window
, private cookie: CookieService
) {
this._status.baseURL = 'http://localhost:' + DEFAULT_GUI_PORT;
this.baseRestUrl = this._status.baseURL + '/rest';
this.apikey = DEFAULT_GUI_API_KEY;
this._status.baseURL = 'http://localhost:' + DEFAULT_GUI_PORT;
this.baseRestUrl = this._status.baseURL + '/rest';
this.apikey = DEFAULT_GUI_API_KEY;
@@
-194,12
+196,14
@@
export class SyncthingService {
// Add or update Folder settings
let label = prj.label || "";
// Add or update Folder settings
let label = prj.label || "";
+ let scanInterval = parseInt(this.cookie.get("st-rescanInterval"), 10) || DEFAULT_RESCAN_INTERV;
let folder: ISTFolderConfiguration = {
id: prj.id,
label: label,
path: prj.path,
devices: [{ deviceID: newDevID, introducedBy: "" }],
autoNormalize: true,
let folder: ISTFolderConfiguration = {
id: prj.id,
label: label,
path: prj.path,
devices: [{ deviceID: newDevID, introducedBy: "" }],
autoNormalize: true,
+ rescanIntervalS: scanInterval,
};
let idx = stCfg.folders.findIndex(item => item.id === prj.id);
};
let idx = stCfg.folders.findIndex(item => item.id === prj.id);