From 1437871d884b88d6b8634b997b1421cf42ea14d2 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Thu, 20 May 2021 18:53:35 -0300 Subject: [PATCH] fix reflector client: only set completed when server says so --- lbry/stream/managed_stream.py | 3 --- tests/unit/stream/test_reflector.py | 5 ++++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lbry/stream/managed_stream.py b/lbry/stream/managed_stream.py index 3e615dfc6..888dca2e2 100644 --- a/lbry/stream/managed_stream.py +++ b/lbry/stream/managed_stream.py @@ -372,9 +372,6 @@ class ManagedStream(ManagedDownloadSource): protocol.transport.close() self.uploading_to_reflector = False - if not self.fully_reflected.is_set(): - self.fully_reflected.set() - await self.blob_manager.storage.update_reflected_stream(self.sd_hash, f"{host}:{port}") return sent async def update_content_claim(self, claim_info: Optional[typing.Dict] = None): diff --git a/tests/unit/stream/test_reflector.py b/tests/unit/stream/test_reflector.py index 89354b3cc..618f7486f 100644 --- a/tests/unit/stream/test_reflector.py +++ b/tests/unit/stream/test_reflector.py @@ -63,13 +63,16 @@ class TestReflector(AsyncioTestCase): if partial_needs: self.assertFalse(self.stream.is_fully_reflected) send_more = await self.stream.upload_to_reflector('127.0.0.1', 5566) - self.assertGreater(0, len(send_more)) + self.assertGreater(len(send_more), 0) sent.extend(send_more) + sent.append(self.stream.sd_hash) self.assertSetEqual( set(sent), set(map(lambda b: b.blob_hash, self.stream.descriptor.blobs[:-1] + [self.blob_manager.get_blob(self.stream.sd_hash)])) ) + send_more = await self.stream.upload_to_reflector('127.0.0.1', 5566) + self.assertEqual(len(send_more), 0) self.assertTrue(self.stream.is_fully_reflected) server_sd_blob = self.server_blob_manager.get_blob(self.stream.sd_hash) self.assertTrue(server_sd_blob.get_is_verified())