diff --git a/lbry/lbry/blob/blob_manager.py b/lbry/lbry/blob/blob_manager.py index 50d414fe3..64ef5f2cb 100644 --- a/lbry/lbry/blob/blob_manager.py +++ b/lbry/lbry/blob/blob_manager.py @@ -69,10 +69,10 @@ class BlobManager: def is_blob_verified(self, blob_hash: str, length: typing.Optional[int] = None) -> bool: if not is_valid_blobhash(blob_hash): raise ValueError(blob_hash) - if blob_hash in self.blobs: - return self.blobs[blob_hash].get_is_verified() if not os.path.isfile(os.path.join(self.blob_dir, blob_hash)): return False + if blob_hash in self.blobs: + return self.blobs[blob_hash].get_is_verified() return self._get_blob(blob_hash, length).get_is_verified() async def setup(self) -> bool: diff --git a/lbry/tests/unit/blob/test_blob_manager.py b/lbry/tests/unit/blob/test_blob_manager.py index 0c9a26cf1..eabcbb625 100644 --- a/lbry/tests/unit/blob/test_blob_manager.py +++ b/lbry/tests/unit/blob/test_blob_manager.py @@ -17,6 +17,18 @@ class TestBlobManager(AsyncioTestCase): self.blob_manager = BlobManager(self.loop, tmp_dir, self.storage, self.config) await self.storage.open() + async def test_memory_blobs_arent_verifie_but_real_ones_are(self): + for save_blobs in (False, True): + await self.setup_blob_manager(save_blobs=save_blobs) + # add a blob file + blob_hash = "7f5ab2def99f0ddd008da71db3a3772135f4002b19b7605840ed1034c8955431bd7079549e65e6b2a3b9c17c773073ed" + blob_bytes = b'1' * ((2 * 2 ** 20) - 1) + blob = self.blob_manager.get_blob(blob_hash, len(blob_bytes)) + blob.save_verified_blob(blob_bytes) + self.assertTrue(blob.get_is_verified()) + self.blob_manager.blob_completed(blob) + self.assertEqual(self.blob_manager.is_blob_verified(blob_hash), save_blobs) + async def test_sync_blob_file_manager_on_startup(self): await self.setup_blob_manager(save_blobs=True)