forked from LBRYCommunity/lbry-sdk
fix node not being set on the downloader in some cases
This commit is contained in:
parent
e8ba5d7606
commit
bbded12923
4 changed files with 14 additions and 3 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue