diff --git a/app.glade b/app.glade
index 5117ac6e..f475eb56 100644
--- a/app.glade
+++ b/app.glade
@@ -278,6 +278,18 @@
+
+
+
+
+
diff --git a/syncthing_gtk/app.py b/syncthing_gtk/app.py
index af5b38a5..b0358ae7 100644
--- a/syncthing_gtk/app.py
+++ b/syncthing_gtk/app.py
@@ -679,9 +679,14 @@ def cb_menu_popup_edit_node(self, *a):
self.open_editor("node-edit", self.rightclick_box["id"])
def cb_menu_popup_delete_repo(self, *a):
- """ Handler for 'edit' context menu item """
+ """ Handler for 'delete' repo context menu item """
# Editing repository
self.check_delete("repo", self.rightclick_box["id"], self.rightclick_box.get_title())
+
+ def cb_menu_popup_rescan_repo(self, *a):
+ """ Handler for 'rescan' context menu item """
+ # Editing repository
+ self.daemon.rescan(self.rightclick_box["id"])
def cb_menu_popup_delete_node(self, *a):
""" Handler for other 'edit' context menu item """
diff --git a/syncthing_gtk/daemon.py b/syncthing_gtk/daemon.py
index 17f0a15d..9bea9f38 100644
--- a/syncthing_gtk/daemon.py
+++ b/syncthing_gtk/daemon.py
@@ -464,9 +464,11 @@ def _rest_post_response(self, sc, results, con, command, data, epoch, callback,
return
# Extract response code
try:
- code = int(response.split("\n")[0].strip("\r\n").split(" ")[1])
+ headers, response = response.split("\r\n\r\n", 1)
+ headers = headers.split("\r\n")
+ code = int(headers[0].split(" ")[1])
if code != 200:
- self._rest_post_error(HTTPException("HTTP error %s" % (code,)), command, data, callback, error_callback, callback_data)
+ self._rest_post_error(HTTPException("HTTP error %s" % (code,), response), command, data, callback, error_callback, callback_data)
return
except Exception:
# That probably wasn't HTTP
@@ -746,12 +748,16 @@ def _syncthing_cb_config_written(self, data, callback, errorcallback, calbackdat
else:
callback(*calbackdata)
- def __syncthing_cb_config_write_failed(self, exception, command, data, callback, errorcallback, calbackdata):
+ def _syncthing_cb_config_write_failed(self, exception, command, data, callback, errorcallback, calbackdata):
if errorcallback == None:
errorcallback(exception)
else:
errorcallback(exception, *calbackdata)
+ def _syncthing_cb_rescan_error(self, exception, command, data, repo_id):
+ print >>sys.stderr, "Warning: Failed to rescan repository %s: %s" % (repo_id, exception.response)
+ self.emit("error", "Warning: Failed to rescan repository %s: %s" % (repo_id, exception.response))
+
def _repo_state_changed(self, rid, state, progress):
"""
Emits event according to last known and new state.
@@ -851,7 +857,7 @@ def write_config(self, config, callback, error_callback=None, *calbackdata):
error_callback(exception) on failure.
Should cause 'config-out-of-sync' event to be raised ASAP.
"""
- self._rest_post("config", config, self._syncthing_cb_config_written, self.__syncthing_cb_config_write_failed, callback, error_callback, calbackdata)
+ self._rest_post("config", config, self._syncthing_cb_config_written, self._syncthing_cb_config_write_failed, callback, error_callback, calbackdata)
def restart(self):
"""
@@ -893,7 +899,14 @@ def get_address(self):
""" Returns tuple address on which daemon listens on. """
return self._address
+ def rescan(self, repo_id):
+ """ Asks daemon to rescan repository """
+ self._rest_post("scan?repo=%s" % (repo_id,), {}, lambda *a: a, self._syncthing_cb_rescan_error, repo_id)
+
class InvalidConfigurationException(RuntimeError): pass
class TLSUnsupportedException(InvalidConfigurationException): pass
-class HTTPException(RuntimeError): pass
+class HTTPException(RuntimeError):
+ def __init__(self, message, response=None):
+ RuntimeError.__init__(self, message)
+ self.response = response
class HTTPAuthException(HTTPException): pass