Merge pull request #430 from lbryio/more-verified-time

missed another verified time check
This commit is contained in:
Job Evers‐Meltzer 2017-01-20 13:34:43 -06:00 committed by GitHub
commit e37fbc4fdb
2 changed files with 6 additions and 4 deletions

View file

@ -309,15 +309,14 @@ class DiskBlobManager(BlobManager):
@rerun_if_locked @rerun_if_locked
def _get_all_verified_blob_hashes(self): def _get_all_verified_blob_hashes(self):
d = self.db_conn.runQuery("select blob_hash, last_verified_time from blobs") d = self.db_conn.runQuery("select blob_hash from blobs")
def get_verified_blobs(blobs): def get_verified_blobs(blobs):
verified_blobs = [] verified_blobs = []
for blob_hash, verified_time in blobs: for blob_hash, in blobs:
file_path = os.path.join(self.blob_dir, blob_hash) file_path = os.path.join(self.blob_dir, blob_hash)
if os.path.isfile(file_path): if os.path.isfile(file_path):
if verified_time > os.path.getctime(file_path): verified_blobs.append(blob_hash)
verified_blobs.append(blob_hash)
return verified_blobs return verified_blobs
d.addCallback(lambda blobs: threads.deferToThread(get_verified_blobs, blobs)) d.addCallback(lambda blobs: threads.deferToThread(get_verified_blobs, blobs))

View file

@ -184,6 +184,9 @@ class AlwaysSend(object):
return d return d
# If an instance has a lot of blobs, this call might get very expensive.
# For reflector, with 50k blobs, it definitely has an impact on the first run
# But doesn't seem to impact performance after that.
@defer.inlineCallbacks @defer.inlineCallbacks
def calculate_available_blob_size(blob_manager): def calculate_available_blob_size(blob_manager):
blob_hashes = yield blob_manager.get_all_verified_blobs() blob_hashes = yield blob_manager.get_all_verified_blobs()