muck with pending_claims... still not sure this is correct

This commit is contained in:
Job Evers 2016-07-28 11:43:47 -05:00
parent 15d276b0bc
commit 39a7f37f35

View file

@ -608,20 +608,25 @@ class LBRYDaemon(jsonrpc.JSONRPC):
return txid
def _check_pending_claims(self):
def _start_file(name):
# TODO: this was blatantly copied from jsonrpc_start_lbry_file. Be DRY.
def _start_file(f):
d = self.lbry_file_manager.toggle_lbry_file_running(f)
return defer.succeed("Started LBRY file")
def _get_and_start_file(name):
d = defer.succeed(self.pending_claims.pop(name))
d.addCallback(lambda _: self._get_lbry_file("name", name, return_json=False))
d.addCallback(lambda l: _start_file(l) if l.stopped else "LBRY file was already running")
def _process_lbry_file(name, lbry_file):
# lbry_file is an instance of ManagedLBRYFileDownloader or None
# TODO: check for sd_hash in addition to txid
ready_to_start = (
lbry_file and
self.pending_claims[name] == lbry_file.txid and
not isinstance(lbry_file['metadata'], str)
self.pending_claims[name] == lbry_file.txid
)
if ready_to_start:
_start_file(name)
_get_and_start_file(name, lbry_file)
else:
re_add_to_pending_claims(name)