convert more to inlineCallbacks
This commit is contained in:
parent
1256beea96
commit
227323b7a4
2 changed files with 14 additions and 28 deletions
|
@ -83,7 +83,6 @@ class CryptStreamDownloader(object):
|
|||
return self.stop()
|
||||
|
||||
def start(self):
|
||||
|
||||
if self.starting is True:
|
||||
raise CurrentlyStartingError()
|
||||
if self.stopping is True:
|
||||
|
@ -94,9 +93,8 @@ class CryptStreamDownloader(object):
|
|||
self.starting = True
|
||||
self.completed = False
|
||||
self.finished_deferred = defer.Deferred()
|
||||
fd = self.finished_deferred
|
||||
d = self._start()
|
||||
d.addCallback(lambda _: fd)
|
||||
d.addCallback(lambda _: self.finished_deferred)
|
||||
return d
|
||||
|
||||
def stop(self, err=None):
|
||||
|
|
|
@ -137,32 +137,20 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver):
|
|||
d.addCallback(make_full_status)
|
||||
return d
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def _start(self):
|
||||
|
||||
d = EncryptedFileSaver._start(self)
|
||||
d.addCallback(
|
||||
lambda _: self.stream_info_manager.get_sd_blob_hashes_for_stream(self.stream_hash))
|
||||
|
||||
def _save_sd_hash(sd_hash):
|
||||
if len(sd_hash):
|
||||
self.sd_hash = sd_hash[0]
|
||||
d = self.wallet.get_claim_metadata_for_sd_hash(self.sd_hash)
|
||||
else:
|
||||
d = defer.succeed(None)
|
||||
|
||||
return d
|
||||
|
||||
def _save_claim(name, txid, nout):
|
||||
self.uri = name
|
||||
self.txid = txid
|
||||
self.nout = nout
|
||||
return defer.succeed(None)
|
||||
|
||||
d.addCallback(_save_sd_hash)
|
||||
d.addCallback(lambda r: _save_claim(r[0], r[1], r[2]) if r else None)
|
||||
d.addCallback(lambda _: self._save_status())
|
||||
|
||||
return d
|
||||
yield EncryptedFileSaver._start(self)
|
||||
sd_hash = yield self.stream_info_manager.get_sd_blob_hashes_for_stream(self.stream_hash)
|
||||
if len(sd_hash):
|
||||
self.sd_hash = sd_hash[0]
|
||||
maybe_metadata = yield self.wallet.get_claim_metadata_for_sd_hash(self.sd_hash)
|
||||
if maybe_metadata:
|
||||
name, txid, nout = maybe_metadata
|
||||
self.uri = name
|
||||
self.txid = txid
|
||||
self.nout = nout
|
||||
status = yield self._save_status()
|
||||
defer.returnValue(status)
|
||||
|
||||
def _get_finished_deferred_callback_value(self):
|
||||
if self.completed is True:
|
||||
|
|
Loading…
Add table
Reference in a new issue