From 3f1bcbffeb583b23e8f8f753cf35bcebe2e8784f Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Wed, 7 Mar 2018 18:25:30 -0500 Subject: [PATCH] fix blob_announce when announcing a single blob --- CHANGELOG.md | 2 +- lbrynet/core/BlobManager.py | 6 +++--- lbrynet/daemon/Daemon.py | 18 +++++++++--------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be70701b2..4b89a203c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ at anytime. ### Fixed * fixed the inconsistencies in API and CLI docstrings - * + * `blob_announce` error when announcing a single blob ### Deprecated * `report_bug` jsonrpc command diff --git a/lbrynet/core/BlobManager.py b/lbrynet/core/BlobManager.py index a2f2eee39..a9142b369 100644 --- a/lbrynet/core/BlobManager.py +++ b/lbrynet/core/BlobManager.py @@ -54,7 +54,7 @@ class DiskBlobManager(DHTHashSupplier): self.blobs[blob_hash] = blob return defer.succeed(blob) - def _immediate_announce(self, blob_hashes): + def immediate_announce(self, blob_hashes): if self.hash_announcer: return self.hash_announcer.immediate_announce(blob_hashes) raise Exception("Hash announcer not set") @@ -69,7 +69,7 @@ class DiskBlobManager(DHTHashSupplier): # we announce all blobs immediately, if announce_head_blob_only is False # otherwise, announce only if marked as should_announce if not self.announce_head_blobs_only or should_announce: - reactor.callLater(0, self._immediate_announce, [blob.blob_hash]) + reactor.callLater(0, self.immediate_announce, [blob.blob_hash]) def completed_blobs(self, blobhashes_to_check): return self._completed_blobs(blobhashes_to_check) @@ -107,7 +107,7 @@ class DiskBlobManager(DHTHashSupplier): def immediate_announce_all_blobs(self): d = self._get_all_verified_blob_hashes() - d.addCallback(self._immediate_announce) + d.addCallback(self.immediate_announce) return d def get_all_verified_blobs(self): diff --git a/lbrynet/daemon/Daemon.py b/lbrynet/daemon/Daemon.py index 419409af2..3e11b0354 100644 --- a/lbrynet/daemon/Daemon.py +++ b/lbrynet/daemon/Daemon.py @@ -2930,17 +2930,17 @@ class Daemon(AuthJSONRPCServer): else: blob_hashes = [] if blob_hash: - blob_hashes = blob_hashes.append(blob_hashes) - elif stream_hash: - pass - elif sd_hash: - stream_hash = yield self.storage.get_stream_hash_for_sd_hash(sd_hash) - else: - raise Exception('single argument must be specified') - if not blob_hash: + blob_hashes.append(blob_hash) + elif stream_hash or sd_hash: + if sd_hash and stream_hash: + raise Exception("either the sd hash or the stream hash should be provided, not both") + if sd_hash: + stream_hash = yield self.storage.get_stream_hash_for_sd_hash(sd_hash) blobs = yield self.storage.get_blobs_for_stream(stream_hash, only_completed=True) blob_hashes.extend([blob.blob_hash for blob in blobs]) - yield self.session.blob_manager._immediate_announce(blob_hashes) + else: + raise Exception('single argument must be specified') + yield self.session.blob_manager.immediate_announce(blob_hashes) response = yield self._render_response(True) defer.returnValue(response)