From ee5be5adc80d4513fbd2fa26881833de3487dd54 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Fri, 31 Aug 2018 10:43:35 -0300 Subject: [PATCH] fail graceful when get is called on inexistent URI --- lbrynet/daemon/Daemon.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/lbrynet/daemon/Daemon.py b/lbrynet/daemon/Daemon.py index 4333e0e46..3098854f9 100644 --- a/lbrynet/daemon/Daemon.py +++ b/lbrynet/daemon/Daemon.py @@ -1853,19 +1853,14 @@ class Daemon(AuthJSONRPCServer): if parsed_uri.is_channel and not parsed_uri.path: raise Exception("cannot download a channel claim, specify a /path") - resolved_result = yield self.wallet_manager.resolve(uri) - if resolved_result and uri in resolved_result: - resolved = resolved_result[uri] - else: - resolved = None + resolved = (yield self.wallet.resolve(uri)).get(uri, {}) + resolved = resolved if 'value' in resolved else resolved.get('claim') + + if not resolved: + raise Exception( + "Failed to resolve stream at lbry://{}".format(uri.replace("lbry://", "")) + ) - if not resolved or 'value' not in resolved: - if 'claim' not in resolved: - raise Exception( - "Failed to resolve stream at lbry://{}".format(uri.replace("lbry://", "")) - ) - else: - resolved = resolved['claim'] txid, nout, name = resolved['txid'], resolved['nout'], resolved['name'] claim_dict = ClaimDict.load_dict(resolved['value']) sd_hash = claim_dict.source_hash.decode()