From c6e614ebec109f7fcdb061f5e44a4fd8c897417b Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Sun, 19 Feb 2017 19:17:25 -0500 Subject: [PATCH] fix get() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -get_file_by_sd_hash raises NoSuchSDHash if there is no file, which otherwise doesn’t get trapped -remove unnecessary try/except around _DownloadNameHelper.__init__ -don’t delete self.waiting_on[name] --- lbrynet/lbrynet_daemon/Daemon.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/lbrynet/lbrynet_daemon/Daemon.py b/lbrynet/lbrynet_daemon/Daemon.py index c6a375e7e..e046725c0 100644 --- a/lbrynet/lbrynet_daemon/Daemon.py +++ b/lbrynet/lbrynet_daemon/Daemon.py @@ -820,17 +820,13 @@ class Daemon(AuthJSONRPCServer): """ timeout = timeout if timeout is not None else conf.settings['download_timeout'] - try: - helper = _DownloadNameHelper(self, name, timeout, download_directory, file_name, - wait_for_write) - except Exception as err: - log.exception(err) - raise err + helper = _DownloadNameHelper(self, name, timeout, download_directory, file_name, + wait_for_write) if not stream_info: self.waiting_on[name] = True stream_info = yield self._resolve_name(name) - del self.waiting_on[name] + lbry_file = yield helper.setup_stream(stream_info) sd_hash, file_path = yield helper.wait_or_get_stream(stream_info, lbry_file) defer.returnValue((sd_hash, file_path)) @@ -2562,10 +2558,7 @@ def get_version_from_tag(tag): def get_sd_hash(stream_info): if not stream_info: return None - try: - return stream_info['sources']['lbry_sd_hash'] - except KeyError: - return stream_info.get('stream_hash') + return stream_info['sources']['lbry_sd_hash'] class _DownloadNameHelper(object): @@ -2584,7 +2577,7 @@ class _DownloadNameHelper(object): @defer.inlineCallbacks def setup_stream(self, stream_info): sd_hash = get_sd_hash(stream_info) - lbry_file = yield self.daemon._get_lbry_file_by_sd_hash(sd_hash) + lbry_file = yield self.daemon._get_lbry_file(FileID.SD_HASH, sd_hash) if self._does_lbry_file_exists(lbry_file): defer.returnValue(lbry_file) else: