From 9afaed8f730b4e73aff9f9b3d11e0a55d9410ea2 Mon Sep 17 00:00:00 2001 From: Allie Crevier Date: Mon, 27 Jan 2020 18:45:02 -0800 Subject: [PATCH] stop metadata sync thread when user logs out --- securedrop_client/logic.py | 2 ++ securedrop_client/sync.py | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/securedrop_client/logic.py b/securedrop_client/logic.py index cfa12dd2f3..35891dbddc 100644 --- a/securedrop_client/logic.py +++ b/securedrop_client/logic.py @@ -347,6 +347,7 @@ def on_authenticate_failure(self, result: Exception) -> None: error = _('There was a problem signing in. ' 'Please verify your credentials and try again.') self.gui.show_login_error(error=error) + self.api_sync.stop() def login_offline_mode(self): """ @@ -493,6 +494,7 @@ def logout(self): self.on_logout_failure) self.api = None self.api_job_queue.logout() + self.api_sync.stop() storage.mark_all_pending_drafts_as_failed(self.session) self.gui.logout() self.is_authenticated = False diff --git a/securedrop_client/sync.py b/securedrop_client/sync.py index d722575947..5bd176d4b4 100644 --- a/securedrop_client/sync.py +++ b/securedrop_client/sync.py @@ -36,7 +36,7 @@ def __init__( def start(self, api_client: API) -> None: ''' - Stop metadata syncs. + Start metadata syncs. ''' self.api_client = api_client @@ -54,7 +54,7 @@ def stop(self): logger.debug('Stopping sync thread') self.sync_thread.quit() - def sync(self): + def _sync(self): ''' Create and run a new MetadataSyncJob. ''' @@ -68,9 +68,9 @@ def sync(self): def on_sync_success(self) -> None: self.sync_success.emit() - QTimer.singleShot(self.TIME_BETWEEN_SYNCS_MS, self.sync) + QTimer.singleShot(self.TIME_BETWEEN_SYNCS_MS, self._sync) def on_sync_failure(self, result: Exception) -> None: self.sync_failure.emit(result) if isinstance(result, RequestTimeoutError): - QTimer.singleShot(self.TIME_BETWEEN_SYNCS_MS, self.sync) + QTimer.singleShot(self.TIME_BETWEEN_SYNCS_MS, self._sync)