From b1db42acf44cd1b79802e4b486542f2e89afb4ed Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Fri, 15 Oct 2021 03:23:45 -0300 Subject: [PATCH] download all blobs and check that on tests --- lbry/extras/daemon/components.py | 3 +++ lbry/stream/managed_stream.py | 4 ++++ tests/integration/datanetwork/test_file_commands.py | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lbry/extras/daemon/components.py b/lbry/extras/daemon/components.py index a5b23d743..c27cb3e09 100644 --- a/lbry/extras/daemon/components.py +++ b/lbry/extras/daemon/components.py @@ -17,6 +17,7 @@ from lbry.dht.blob_announcer import BlobAnnouncer from lbry.blob.blob_manager import BlobManager from lbry.blob.disk_space_manager import DiskSpaceManager from lbry.blob_exchange.server import BlobServer +from lbry.stream.managed_stream import ManagedStream from lbry.stream.stream_manager import StreamManager from lbry.file.file_manager import FileManager from lbry.extras.daemon.component import Component @@ -421,6 +422,8 @@ class BackgroundDownloader(Component): stream = await file_manager.download_from_uri( claim.permanent_url, None, 60.0, save_file=False, wallet=wallet ) + if isinstance(stream, ManagedStream): + await stream.save_blobs() amount -= 1 if amount == 0: break diff --git a/lbry/stream/managed_stream.py b/lbry/stream/managed_stream.py index 2a85da66e..aee4bbc72 100644 --- a/lbry/stream/managed_stream.py +++ b/lbry/stream/managed_stream.py @@ -246,6 +246,10 @@ class ManagedStream(ManagedDownloadSource): handle.write(data) handle.flush() + async def save_blobs(self): + async for _ in self._aiter_read_stream(0, connection_id=self.STREAMING_ID): + pass + async def _save_file(self, output_path: str): log.info("save file for lbry://%s#%s (sd hash %s...) -> %s", self.claim_name, self.claim_id, self.sd_hash[:6], output_path) diff --git a/tests/integration/datanetwork/test_file_commands.py b/tests/integration/datanetwork/test_file_commands.py index 424bb0f2b..c8d333cf1 100644 --- a/tests/integration/datanetwork/test_file_commands.py +++ b/tests/integration/datanetwork/test_file_commands.py @@ -576,7 +576,7 @@ class DiskSpaceManagement(CommandTestCase): class TestProactiveDownloaderComponent(CommandTestCase): async def assertFileList(self, *txos): txos_names = {txo['outputs'][0]['name'] for txo in txos} - files = await self.file_list() + files = await self.file_list(blobs_remaining=0) self.assertEqual(len(txos), len(files)) file_claim_names = {file['claim_name'] for file in files} self.assertSetEqual(txos_names, file_claim_names)