change stop to be an inlineCallback

This commit is contained in:
Job Evers-Meltzer 2017-01-11 11:53:43 -06:00
parent 9366a6e561
commit a9261b2032

View file

@ -42,7 +42,11 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver):
self.claim_id = None self.claim_id = None
self.rowid = rowid self.rowid = rowid
self.lbry_file_manager = lbry_file_manager self.lbry_file_manager = lbry_file_manager
self.saving_status = False self._saving_status = False
@property
def saving_status(self):
return self._saving_status
def restore(self): def restore(self):
d = self.stream_info_manager._get_sd_blob_hashes_for_stream(self.stream_hash) d = self.stream_info_manager._get_sd_blob_hashes_for_stream(self.stream_hash)
@ -96,18 +100,15 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver):
reflector_server = random.choice(conf.settings.reflector_servers) reflector_server = random.choice(conf.settings.reflector_servers)
return reupload.check_and_restore_availability(self, reflector_server) return reupload.check_and_restore_availability(self, reflector_server)
@defer.inlineCallbacks
def stop(self, err=None, change_status=True): def stop(self, err=None, change_status=True):
log.debug('Stopping download for %s', self.sd_hash)
def set_saving_status_done():
self.saving_status = False
# 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.
d = 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 self._saving_status = True
d.addCallback(lambda _: self._save_status()) status = yield self._save_status()
d.addCallback(lambda _: set_saving_status_done()) self._saving_status = False
return d
def status(self): def status(self):
def find_completed_blobhashes(blobs): def find_completed_blobhashes(blobs):