diff --git a/lbry/extras/daemon/daemon.py b/lbry/extras/daemon/daemon.py index fd4627987..441d4b93a 100644 --- a/lbry/extras/daemon/daemon.py +++ b/lbry/extras/daemon/daemon.py @@ -2046,6 +2046,8 @@ class Daemon(metaclass=JSONRPCServerType): raise Exception(f'Unable to find a file for {kwargs}') stream = streams[0] if status == 'start' and not stream.running: + if not hasattr(stream, 'bt_infohash') and 'dht' not in self.conf.components_to_skip: + stream.downloader.node = self.dht_node await stream.save_file() msg = "Resumed download" elif status == 'stop' and stream.running: @@ -2148,6 +2150,8 @@ class Daemon(metaclass=JSONRPCServerType): log.warning("There is no file to save") return False stream = streams[0] + if not hasattr(stream, 'bt_infohash') and 'dht' not in self.conf.components_to_skip: + stream.downloader.node = self.dht_node await stream.save_file(file_name, download_directory) return stream diff --git a/lbry/file/file_manager.py b/lbry/file/file_manager.py index 0c1eb7069..906362858 100644 --- a/lbry/file/file_manager.py +++ b/lbry/file/file_manager.py @@ -142,6 +142,8 @@ class FileManager: log.info("claim contains an update to a stream we have, downloading it") if save_file and existing_for_claim_id[0].output_file_exists: save_file = False + if not claim.stream.source.bt_infohash: + existing_for_claim_id[0].downloader.node = source_manager.node await existing_for_claim_id[0].start(timeout=timeout, save_now=save_file) if not existing_for_claim_id[0].output_file_exists and ( save_file or file_name or download_directory): @@ -155,6 +157,8 @@ class FileManager: log.info("already have stream for %s", uri) if save_file and updated_stream.output_file_exists: save_file = False + if not claim.stream.source.bt_infohash: + updated_stream.downloader.node = source_manager.node await updated_stream.start(timeout=timeout, save_now=save_file) if not updated_stream.output_file_exists and (save_file or file_name or download_directory): await updated_stream.save_file( diff --git a/lbry/stream/managed_stream.py b/lbry/stream/managed_stream.py index debd987a4..73976a8a3 100644 --- a/lbry/stream/managed_stream.py +++ b/lbry/stream/managed_stream.py @@ -193,13 +193,13 @@ class ManagedStream(ManagedDownloadSource): decrypted = await self.downloader.read_blob(blob_info, connection_id) yield (blob_info, decrypted) - async def stream_file(self, request: Request, node: Optional['Node'] = None) -> StreamResponse: + async def stream_file(self, request: Request) -> StreamResponse: log.info("stream file to browser for lbry://%s#%s (sd hash %s...)", self.claim_name, self.claim_id, self.sd_hash[:6]) headers, size, skip_blobs, first_blob_start_offset = self._prepare_range_response_headers( request.headers.get('range', 'bytes=0-') ) - await self.start(node) + await self.start() response = StreamResponse( status=206, headers=headers diff --git a/lbry/stream/stream_manager.py b/lbry/stream/stream_manager.py index 4d0d1093b..8e66aff96 100644 --- a/lbry/stream/stream_manager.py +++ b/lbry/stream/stream_manager.py @@ -247,4 +247,7 @@ class StreamManager(SourceManager): os.remove(source.full_path) async def stream_partial_content(self, request: Request, sd_hash: str): - return await self._sources[sd_hash].stream_file(request, self.node) + stream = self._sources[sd_hash] + if not stream.downloader.node: + stream.downloader.node = self.node + return await stream.stream_file(request)