diff options
author | Jakob Borg <jakob@nym.se> | 2014-06-20 00:27:54 +0200 |
---|---|---|
committer | Jakob Borg <jakob@nym.se> | 2014-06-20 00:28:45 +0200 |
commit | efbdf72d200b3fa94a817d04b93f683689d07d54 (patch) | |
tree | caf0cdf01c9a266216b97837ed97072f62c23067 /cmd | |
parent | 0e59b5678ac4ceb513fa0a45e6f7db93f7678470 (diff) |
Lower CPU usage at idle by reducing db polling
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/syncthing/gui.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/cmd/syncthing/gui.go b/cmd/syncthing/gui.go index 02e68a8093..8a57d53253 100644 --- a/cmd/syncthing/gui.go +++ b/cmd/syncthing/gui.go @@ -91,6 +91,7 @@ func startGUI(cfg config.GUIConfiguration, assetDir string, m *model.Model) erro router.Get("/", getRoot) router.Get("/rest/version", restGetVersion) router.Get("/rest/model", restGetModel) + router.Get("/rest/model/version", restGetModelVersion) router.Get("/rest/need", restGetNeed) router.Get("/rest/connections", restGetConnections) router.Get("/rest/config", restGetConfig) @@ -144,6 +145,17 @@ func restGetVersion() string { return Version } +func restGetModelVersion(m *model.Model, w http.ResponseWriter, r *http.Request) { + var qs = r.URL.Query() + var repo = qs.Get("repo") + var res = make(map[string]interface{}) + + res["version"] = m.Version(repo) + + w.Header().Set("Content-Type", "application/json") + json.NewEncoder(w).Encode(res) +} + func restGetModel(m *model.Model, w http.ResponseWriter, r *http.Request) { var qs = r.URL.Query() var repo = qs.Get("repo") @@ -168,6 +180,7 @@ func restGetModel(m *model.Model, w http.ResponseWriter, r *http.Request) { res["inSyncFiles"], res["inSyncBytes"] = globalFiles-needFiles, globalBytes-needBytes res["state"] = m.State(repo) + res["version"] = m.Version(repo) w.Header().Set("Content-Type", "application/json") json.NewEncoder(w).Encode(res) |