diff --git a/lbrynet/lbrynet_daemon/LBRYDaemon.py b/lbrynet/lbrynet_daemon/LBRYDaemon.py index a44607505..555e1deff 100644 --- a/lbrynet/lbrynet_daemon/LBRYDaemon.py +++ b/lbrynet/lbrynet_daemon/LBRYDaemon.py @@ -134,6 +134,7 @@ class LBRYDaemon(jsonrpc.JSONRPC): self.current_db_revision = 1 self.run_server = True self.session = None + self.waiting_on = {} self.known_dht_nodes = KNOWN_DHT_NODES self.platform_info = { "processor": platform.processor(), @@ -867,6 +868,10 @@ class LBRYDaemon(jsonrpc.JSONRPC): elif not os.path.isdir(download_directory): download_directory = self.download_directory + def _remove_from_wait(r): + del self.waiting_on[name] + return r + def _disp_file(f): file_path = os.path.join(self.download_directory, f.file_name) log.info("[" + str(datetime.now()) + "] Already downloaded: " + str(f.stream_hash) + " --> " + file_path) @@ -891,8 +896,10 @@ class LBRYDaemon(jsonrpc.JSONRPC): return d + self.waiting_on[name] = True d = self._check_history(name) d.addCallback(lambda lbry_file: _get_stream(name) if not lbry_file else _disp_file(lbry_file)) + d.addCallback(_remove_from_wait) return d @@ -1382,8 +1389,11 @@ class LBRYDaemon(jsonrpc.JSONRPC): if 'name' in p.keys(): name = p['name'] - d = self._download_name(name=name, timeout=timeout, download_directory=download_directory) - d.addCallback(lambda message: self._render_response(message, OK_CODE)) + if p['name'] not in self.waiting_on.keys(): + d = self._download_name(name=name, timeout=timeout, download_directory=download_directory) + d.addCallback(lambda message: self._render_response(message, OK_CODE)) + else: + d = server.failure else: d = server.failure diff --git a/lbrynet/lbrynet_daemon/LBRYDownloader.py b/lbrynet/lbrynet_daemon/LBRYDownloader.py index 32622534c..c8cdc7fbb 100644 --- a/lbrynet/lbrynet_daemon/LBRYDownloader.py +++ b/lbrynet/lbrynet_daemon/LBRYDownloader.py @@ -123,7 +123,6 @@ class GetStream(object): self.download_path = os.path.join(downloader.download_directory, downloader.file_name) d.addCallback(lambda _: log.info("Downloading " + str(self.stream_hash) + " --> " + str(self.download_path))) d.addCallback(lambda _: downloader.start()) - d.callback() class FetcherDaemon(object): def __init__(self, session, lbry_file_manager, lbry_file_metadata_manager, wallet, sd_identifier, autofetcher_conf,