fix blob_announce command

This commit is contained in:
Jack Robison 2018-03-01 16:42:52 -05:00
parent 01c4c6ed97
commit 7862ee6715
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
2 changed files with 9 additions and 7 deletions

View file

@ -2801,6 +2801,7 @@ class Daemon(AuthJSONRPCServer):
Returns:
(bool) true if successful
"""
if announce_all:
yield self.session.blob_manager.immediate_announce_all_blobs()
else:
@ -2814,11 +2815,9 @@ class Daemon(AuthJSONRPCServer):
else:
raise Exception('single argument must be specified')
if not blob_hash:
blobs = yield self.storage.get_blobs_for_stream(stream_hash)
blob_hashes.extend([blob.blob_hash for blob in blobs if blob.get_is_verified()])
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)
response = yield self._render_response(True)
defer.returnValue(response)

View file

@ -389,11 +389,14 @@ class SQLiteStorage(object):
stream_hash, blob_num
)
def get_blobs_for_stream(self, stream_hash):
def get_blobs_for_stream(self, stream_hash, only_completed=False):
def _get_blobs_for_stream(transaction):
crypt_blob_infos = []
stream_blobs = transaction.execute("select blob_hash, position, iv from stream_blob "
"where stream_hash=?", (stream_hash, )).fetchall()
if only_completed:
query = "select blob_hash, position, iv from stream_blob where stream_hash=? and status='finished'"
else:
query = "select blob_hash, position, iv from stream_blob where stream_hash=?"
stream_blobs = transaction.execute(query, (stream_hash, )).fetchall()
if stream_blobs:
for blob_hash, position, iv in stream_blobs:
if blob_hash is not None: