merge with change stop to be an inlineCallback

This commit is contained in:
Job Evers-Meltzer 2017-01-13 08:16:42 -06:00
parent a9261b2032
commit e61260a263

View file

@ -106,9 +106,7 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver):
# EncryptedFileSaver deletes metadata when it's stopped. We don't want that here. # EncryptedFileSaver deletes metadata when it's stopped. We don't want that here.
yield EncryptedFileDownloader.stop(self, err=err) yield EncryptedFileDownloader.stop(self, err=err)
if change_status is True: if change_status is True:
self._saving_status = True
status = yield self._save_status() status = yield self._save_status()
self._saving_status = False
def status(self): def status(self):
def find_completed_blobhashes(blobs): def find_completed_blobhashes(blobs):
@ -159,14 +157,17 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver):
else: else:
return "Download stopped" return "Download stopped"
@defer.inlineCallbacks
def _save_status(self): def _save_status(self):
self._saving_status = True
if self.completed is True: if self.completed is True:
s = ManagedEncryptedFileDownloader.STATUS_FINISHED status = ManagedEncryptedFileDownloader.STATUS_FINISHED
elif self.stopped is True: elif self.stopped is True:
s = ManagedEncryptedFileDownloader.STATUS_STOPPED status = ManagedEncryptedFileDownloader.STATUS_STOPPED
else: else:
s = ManagedEncryptedFileDownloader.STATUS_RUNNING status = ManagedEncryptedFileDownloader.STATUS_RUNNING
return self.lbry_file_manager.change_lbry_file_status(self, s) yield self.lbry_file_manager.change_lbry_file_status(self, status)
self._saving_status = False
def _get_progress_manager(self, download_manager): def _get_progress_manager(self, download_manager):
return FullStreamProgressManager(self._finished_downloading, return FullStreamProgressManager(self._finished_downloading,