Skip to content

Commit

Permalink
remove sync_api call and metadata sync queue
Browse files Browse the repository at this point in the history
  • Loading branch information
Allie Crevier committed Jan 30, 2020
1 parent 24bf3e5 commit 37ff3db
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 33 deletions.
21 changes: 0 additions & 21 deletions securedrop_client/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
from securedrop_client import storage
from securedrop_client import db
from securedrop_client.sync import ApiSync
from securedrop_client.api_jobs.sync import MetadataSyncJob
from securedrop_client.api_jobs.downloads import FileDownloadJob, MessageDownloadJob, \
ReplyDownloadJob, DownloadChecksumMismatchException
from securedrop_client.api_jobs.sources import DeleteSourceJob
Expand Down Expand Up @@ -373,26 +372,6 @@ def authenticated(self):
"""
return bool(self.api and self.api.token is not None)

def sync_api(self):
"""
Grab data from the remote SecureDrop API in a non-blocking manner.
TODO: This should be removed once sync_api calls have been removed from all the different
job handlers.
"""
logger.debug("In sync_api on thread {}".format(self.thread().currentThreadId()))
if self.authenticated():
logger.debug("You are authenticated, going to make your call")

job = MetadataSyncJob(self.data_dir, self.gpg)
job.success_signal.connect(self.on_sync_success, type=Qt.QueuedConnection)
job.failure_signal.connect(self.on_sync_failure, type=Qt.QueuedConnection)

self.api_job_queue.enqueue(job)

logger.debug("In sync_api, after call to submit job to queue, on "
"thread {}".format(self.thread().currentThreadId()))

def last_sync(self):
"""
Returns the time of last synchronisation with the remote SD server.
Expand Down
15 changes: 3 additions & 12 deletions securedrop_client/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from securedrop_client.api_jobs.base import ApiJob, ApiInaccessibleError, DEFAULT_NUM_ATTEMPTS, \
PauseQueueJob
from securedrop_client.api_jobs.sync import MetadataSyncJob
from securedrop_client.api_jobs.downloads import (FileDownloadJob, MessageDownloadJob,
ReplyDownloadJob)
from securedrop_client.api_jobs.sources import DeleteSourceJob
Expand Down Expand Up @@ -47,7 +46,6 @@ class RunnableQueue(QObject):
DeleteSourceJob: 14,
SendReplyJob: 15,
UpdateStarJob: 16,
MetadataSyncJob: 17,
MessageDownloadJob: 18,
ReplyDownloadJob: 18,
}
Expand Down Expand Up @@ -85,12 +83,7 @@ def add_job(self, job: ApiJob) -> None:
current_order_number = next(self.order_number)
job.order_number = current_order_number
priority = self.JOB_PRIORITIES[type(job)]
try:
self.queue.put_nowait((priority, job))
except Full:
# Pass silently if the queue is full. For use with MetadataSyncJob.
# See #652.
pass
self.queue.put_nowait((priority, job))

def re_add_job(self, job: ApiJob) -> None:
'''
Expand Down Expand Up @@ -190,12 +183,10 @@ def on_queue_paused(self) -> None:

def resume_queues(self) -> None:
logger.info("Resuming queues")
main_paused = not self.main_thread.isRunning()
download_paused = not self.download_file_thread.isRunning()
self.start_queues()
if main_paused:
if not self.main_thread.isRunning():
self.main_queue.resume.emit()
if download_paused:
if not self.download_file_thread.isRunning():
self.download_file_queue.resume.emit()

def enqueue(self, job: ApiJob) -> None:
Expand Down

0 comments on commit 37ff3db

Please sign in to comment.