From b39c26fc86437e56f8ba52ff8b8517f46e2341b2 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Fri, 22 Oct 2021 02:55:59 -0300 Subject: [PATCH] announce orphan blobs manually, as that was done when save stream --- lbry/extras/daemon/components.py | 2 ++ lbry/extras/daemon/storage.py | 5 +++++ tests/integration/datanetwork/test_file_commands.py | 3 +++ 3 files changed, 10 insertions(+) diff --git a/lbry/extras/daemon/components.py b/lbry/extras/daemon/components.py index 2b07c4a76..e919e8519 100644 --- a/lbry/extras/daemon/components.py +++ b/lbry/extras/daemon/components.py @@ -421,6 +421,7 @@ class BackgroundDownloader(Component): return blob_manager = self.component_manager.get_component(BLOB_COMPONENT) downloader = StreamDownloader(asyncio.get_running_loop(), self.conf, blob_manager, sd_hash) + storage = blob_manager.storage node = None if self.component_manager.has_component(DHT_COMPONENT): node = self.component_manager.get_component(DHT_COMPONENT) @@ -430,6 +431,7 @@ class BackgroundDownloader(Component): return for blob_info in downloader.descriptor.blobs[:-1]: await downloader.download_stream_blob(blob_info) + await storage.set_announce(sd_hash, downloader.descriptor.blobs[0].blob_hash) async def start(self): self.task = asyncio.create_task(self.loop()) diff --git a/lbry/extras/daemon/storage.py b/lbry/extras/daemon/storage.py index ea8cf5fcc..a0aa29adc 100644 --- a/lbry/extras/daemon/storage.py +++ b/lbry/extras/daemon/storage.py @@ -380,6 +380,11 @@ class SQLiteStorage(SQLiteMixin): "select status from blob where blob_hash=?", blob_hash ) + def set_announce(self, *blob_hashes): + return self.db.execute_fetchall( + "update blob set should_announce=1 where blob_hash in (?, ?)", blob_hashes + ) + def update_last_announced_blobs(self, blob_hashes: typing.List[str]): def _update_last_announced_blobs(transaction: sqlite3.Connection): last_announced = self.time_getter() diff --git a/tests/integration/datanetwork/test_file_commands.py b/tests/integration/datanetwork/test_file_commands.py index 4ff956047..b7d4a05ad 100644 --- a/tests/integration/datanetwork/test_file_commands.py +++ b/tests/integration/datanetwork/test_file_commands.py @@ -584,10 +584,13 @@ class TestProactiveDownloaderComponent(CommandTestCase): async def assertBlobs(self, *sd_hashes, no_files=True): # checks that we have ony the finished blobs needed for the the referenced streams seen = set(sd_hashes) + to_announce = await self.daemon.storage.get_blobs_to_announce() for sd_hash in sd_hashes: + self.assertIn(sd_hash, to_announce) sd_blob = self.daemon.blob_manager.get_blob(sd_hash) self.assertTrue(sd_blob.get_is_verified()) blobs = await self.get_blobs_from_sd_blob(sd_blob) + self.assertIn(blobs[0].blob_hash, to_announce) for blob in blobs[:-1]: self.assertTrue(self.daemon.blob_manager.get_blob(blob.blob_hash).get_is_verified()) seen.update(blob.blob_hash for blob in blobs if blob.blob_hash)