forked from LBRYCommunity/lbry-sdk
refactor, dont call storage from blob_manager + missing await
This commit is contained in:
parent
d035c13883
commit
38ed212c01
1 changed files with 15 additions and 12 deletions
|
@ -302,18 +302,8 @@ class StreamManager:
|
||||||
downloader.stop()
|
downloader.stop()
|
||||||
log.info("stopped stream")
|
log.info("stopped stream")
|
||||||
raise DownloadSDTimeout(downloader.sd_hash)
|
raise DownloadSDTimeout(downloader.sd_hash)
|
||||||
file_name = os.path.basename(downloader.output_path)
|
rowid = await self._store_stream(downloader)
|
||||||
download_directory = os.path.dirname(downloader.output_path)
|
await self.storage.save_content_claim(
|
||||||
if not await self.blob_manager.storage.stream_exists(downloader.sd_hash):
|
|
||||||
await self.blob_manager.storage.store_stream(downloader.sd_blob, downloader.descriptor)
|
|
||||||
if not await self.blob_manager.storage.file_exists(downloader.sd_hash):
|
|
||||||
rowid = await self.blob_manager.storage.save_downloaded_file(
|
|
||||||
downloader.descriptor.stream_hash, file_name, download_directory,
|
|
||||||
0.0
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
rowid = self.blob_manager.storage.rowid_for_stream(downloader.descriptor.stream_hash)
|
|
||||||
await self.blob_manager.storage.save_content_claim(
|
|
||||||
downloader.descriptor.stream_hash, f"{claim_info['txid']}:{claim_info['nout']}"
|
downloader.descriptor.stream_hash, f"{claim_info['txid']}:{claim_info['nout']}"
|
||||||
)
|
)
|
||||||
stream = ManagedStream(self.loop, self.blob_manager, rowid, downloader.descriptor, download_directory,
|
stream = ManagedStream(self.loop, self.blob_manager, rowid, downloader.descriptor, download_directory,
|
||||||
|
@ -330,6 +320,19 @@ class StreamManager:
|
||||||
await self.stop_stream(stream)
|
await self.stop_stream(stream)
|
||||||
raise DownloadDataTimeout(downloader.sd_hash)
|
raise DownloadDataTimeout(downloader.sd_hash)
|
||||||
|
|
||||||
|
async def _store_stream(self, downloader: StreamDownloader) -> int:
|
||||||
|
file_name = os.path.basename(downloader.output_path)
|
||||||
|
download_directory = os.path.dirname(downloader.output_path)
|
||||||
|
if not await self.storage.stream_exists(downloader.sd_hash):
|
||||||
|
await self.storage.store_stream(downloader.sd_blob, downloader.descriptor)
|
||||||
|
if not await self.storage.file_exists(downloader.sd_hash):
|
||||||
|
return await self.storage.save_downloaded_file(
|
||||||
|
downloader.descriptor.stream_hash, file_name, download_directory,
|
||||||
|
0.0
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return await self.storage.rowid_for_stream(downloader.descriptor.stream_hash)
|
||||||
|
|
||||||
async def download_stream_from_claim(self, node: 'Node', claim_info: typing.Dict,
|
async def download_stream_from_claim(self, node: 'Node', claim_info: typing.Dict,
|
||||||
file_name: typing.Optional[str] = None,
|
file_name: typing.Optional[str] = None,
|
||||||
timeout: typing.Optional[float] = 60,
|
timeout: typing.Optional[float] = 60,
|
||||||
|
|
Loading…
Add table
Reference in a new issue