deprecated blob_announce_all

This commit is contained in:
Alex Grintsvayg 2017-09-20 11:16:08 -04:00
parent 1b2bd871f4
commit c98197f266
3 changed files with 15 additions and 22 deletions

View file

@ -17,7 +17,7 @@ at anytime.
* *
### Deprecated ### Deprecated
* * Deprecated `blob_announce_all` JSONRPC command. Use `blob_announce` instead.
* *
### Changed ### Changed

View file

@ -2462,27 +2462,23 @@ class Daemon(AuthJSONRPCServer):
""" """
if announce_all: if announce_all:
yield self.session.blob_manager.immediate_announce_all_blobs() yield self.session.blob_manager.immediate_announce_all_blobs()
elif blob_hash: else:
if blob_hash:
blob_hashes = [blob_hash] blob_hashes = [blob_hash]
yield self.session.blob_manager._immediate_announce(blob_hashes)
elif stream_hash: elif stream_hash:
blobs = yield self.get_blobs_for_stream_hash(stream_hash) blobs = yield self.get_blobs_for_stream_hash(stream_hash)
blobs = [blob for blob in blobs if blob.is_validated()] blob_hashes = [blob.blob_hash for blob in blobs if blob.is_validated()]
blob_hashes = [blob.blob_hash for blob in blobs]
yield self.session.blob_manager._immediate_announce(blob_hashes)
elif sd_hash: elif sd_hash:
blobs = yield self.get_blobs_for_sd_hash(sd_hash) blobs = yield self.get_blobs_for_sd_hash(sd_hash)
blobs = [blob for blob in blobs if blob.is_validated()] blob_hashes = [sd_hash] + [blob.blob_hash for blob in blobs if blob.is_validated()]
blob_hashes = [blob.blob_hash for blob in blobs]
blob_hashes.append(sd_hash)
yield self.session.blob_manager._immediate_announce(blob_hashes)
else: else:
raise Exception('single argument must be specified') 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)
# TODO: This command should be deprecated in favor of blob_announce @AuthJSONRPCServer.deprecated("blob_announce")
def jsonrpc_blob_announce_all(self): def jsonrpc_blob_announce_all(self):
""" """
Announce all blobs to the DHT Announce all blobs to the DHT
@ -2493,10 +2489,7 @@ class Daemon(AuthJSONRPCServer):
Returns: Returns:
(str) Success/fail message (str) Success/fail message
""" """
return self.jsonrpc_blob_announce(announce_all=True)
d = self.session.blob_manager.immediate_announce_all_blobs()
d.addCallback(lambda _: self._render_response("Announced"))
return d
@defer.inlineCallbacks @defer.inlineCallbacks
def jsonrpc_file_reflect(self, **kwargs): def jsonrpc_file_reflect(self, **kwargs):

View file

@ -250,7 +250,7 @@ class EncryptedFileManager(object):
if self.sql_db: if self.sql_db:
yield self.sql_db.close() yield self.sql_db.close()
self.sql_db = None self.sql_db = None
log.info("Stopped %s", self) log.info("Stopped encrypted file manager")
defer.returnValue(True) defer.returnValue(True)
def get_count_for_stream_hash(self, stream_hash): def get_count_for_stream_hash(self, stream_hash):