diff options
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/leap/soledad/client/api.py | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/client/src/leap/soledad/client/api.py b/client/src/leap/soledad/client/api.py index b8409cbe..35b44ac8 100644 --- a/client/src/leap/soledad/client/api.py +++ b/client/src/leap/soledad/client/api.py @@ -44,6 +44,7 @@ from u1db.remote.ssl_match_hostname import match_hostname from zope.interface import implements from twisted.python import log +from twisted.internet import defer from leap.common.config import get_path_prefix @@ -654,18 +655,20 @@ class Soledad(object): return local_gen sync_url = urlparse.urljoin(self._server_url, 'user-%s' % self.uuid) - try: - d = self._dbsyncer.sync( - sync_url, - creds=self._creds, autocreate=False, - defer_decryption=defer_decryption) - - d.addCallbacks(on_sync_done, lambda err: log.err(err)) - return d - - # TODO catch the exception by adding an Errback - except Exception as e: - logger.error("Soledad exception when syncing: %s" % str(e)) + d = self._dbsyncer.sync( + sync_url, + creds=self._creds, autocreate=False, + defer_decryption=defer_decryption) + + # prevent sync failures from crashing the app by adding an errback + # that logs the failure and does not propagate it down the callback + # chain + def _errback(failure): + log.err(failure) + logger.error("Soledad exception when syncing: %s" % str(failure)) + + d.addCallbacks(on_sync_done, _errback) + return d def stop_sync(self): self._dbsyncer.stop_sync() |