diff --git a/cmd/syncthing/gui.go b/cmd/syncthing/gui.go index ac89d6f7d..c5aa4b31c 100644 --- a/cmd/syncthing/gui.go +++ b/cmd/syncthing/gui.go @@ -157,19 +157,28 @@ func restGetConfigInSync(w http.ResponseWriter) { json.NewEncoder(w).Encode(map[string]bool{"configInSync": configInSync}) } -func restPostRestart() { +func restPostRestart(w http.ResponseWriter) { + flushResponse(`{"ok": "restarting"}`, w) go restart() } -func restPostReset() { +func restPostReset(w http.ResponseWriter) { + flushResponse(`{"ok": "resetting repos"}`, w) resetRepositories() go restart() } -func restPostShutdown() { +func restPostShutdown(w http.ResponseWriter) { + flushResponse(`{"ok": "shutting down"}`, w) go shutdown() } +func flushResponse(s string, w http.ResponseWriter) { + w.Write([]byte(s + "\n")) + f := w.(http.Flusher) + f.Flush() +} + var cpuUsagePercent [10]float64 // The last ten seconds var cpuUsageLock sync.RWMutex