fix blob_announce when announcing a single blob

This commit is contained in:
Jack Robison 2018-03-07 18:25:30 -05:00
parent 5f35cb43c8
commit 3f1bcbffeb
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
3 changed files with 13 additions and 13 deletions

View file

@ -14,7 +14,7 @@ at anytime.
### Fixed ### Fixed
* fixed the inconsistencies in API and CLI docstrings * fixed the inconsistencies in API and CLI docstrings
* * `blob_announce` error when announcing a single blob
### Deprecated ### Deprecated
* `report_bug` jsonrpc command * `report_bug` jsonrpc command

View file

@ -54,7 +54,7 @@ class DiskBlobManager(DHTHashSupplier):
self.blobs[blob_hash] = blob self.blobs[blob_hash] = blob
return defer.succeed(blob) return defer.succeed(blob)
def _immediate_announce(self, blob_hashes): def immediate_announce(self, blob_hashes):
if self.hash_announcer: if self.hash_announcer:
return self.hash_announcer.immediate_announce(blob_hashes) return self.hash_announcer.immediate_announce(blob_hashes)
raise Exception("Hash announcer not set") 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 # we announce all blobs immediately, if announce_head_blob_only is False
# otherwise, announce only if marked as should_announce # otherwise, announce only if marked as should_announce
if not self.announce_head_blobs_only or 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): def completed_blobs(self, blobhashes_to_check):
return self._completed_blobs(blobhashes_to_check) return self._completed_blobs(blobhashes_to_check)
@ -107,7 +107,7 @@ class DiskBlobManager(DHTHashSupplier):
def immediate_announce_all_blobs(self): def immediate_announce_all_blobs(self):
d = self._get_all_verified_blob_hashes() d = self._get_all_verified_blob_hashes()
d.addCallback(self._immediate_announce) d.addCallback(self.immediate_announce)
return d return d
def get_all_verified_blobs(self): def get_all_verified_blobs(self):

View file

@ -2930,17 +2930,17 @@ class Daemon(AuthJSONRPCServer):
else: else:
blob_hashes = [] blob_hashes = []
if blob_hash: if blob_hash:
blob_hashes = blob_hashes.append(blob_hashes) blob_hashes.append(blob_hash)
elif stream_hash: elif stream_hash or sd_hash:
pass if sd_hash and stream_hash:
elif sd_hash: raise Exception("either the sd hash or the stream hash should be provided, not both")
stream_hash = yield self.storage.get_stream_hash_for_sd_hash(sd_hash) if sd_hash:
else: stream_hash = yield self.storage.get_stream_hash_for_sd_hash(sd_hash)
raise Exception('single argument must be specified')
if not blob_hash:
blobs = yield self.storage.get_blobs_for_stream(stream_hash, only_completed=True) blobs = yield self.storage.get_blobs_for_stream(stream_hash, only_completed=True)
blob_hashes.extend([blob.blob_hash for blob in blobs]) 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) response = yield self._render_response(True)
defer.returnValue(response) defer.returnValue(response)