Fix borg-check --verify-data tripping over ObjectNotFounds

This commit is contained in:
Marian Beermann 2016-07-28 18:40:20 +02:00
parent 794296722f
commit 1b6b0cfae6
1 changed files with 12 additions and 7 deletions

View File

@ -954,20 +954,25 @@ class ArchiveChecker:
def verify_data(self):
logger.info('Starting cryptographic data integrity verification...')
pi = ProgressIndicatorPercent(total=len(self.chunks), msg="Verifying data %6.2f%%", step=0.01, same_line=True)
count = errors = 0
count = len(self.chunks)
errors = 0
pi = ProgressIndicatorPercent(total=count, msg="Verifying data %6.2f%%", step=0.01, same_line=True)
for chunk_id, (refcount, *_) in self.chunks.iteritems():
pi.show()
if not refcount:
continue
encrypted_data = self.repository.get(chunk_id)
try:
_, data = self.key.decrypt(chunk_id, encrypted_data)
encrypted_data = self.repository.get(chunk_id)
except Repository.ObjectNotFound:
self.error_found = True
errors += 1
logger.error('chunk %s not found', bin_to_hex(chunk_id))
continue
try:
_chunk_id = None if chunk_id == Manifest.MANIFEST_ID else chunk_id
_, data = self.key.decrypt(_chunk_id, encrypted_data)
except IntegrityError as integrity_error:
self.error_found = True
errors += 1
logger.error('chunk %s, integrity error: %s', bin_to_hex(chunk_id), integrity_error)
count += 1
pi.finish()
log = logger.error if errors else logger.info
log('Finished cryptographic data integrity verification, verified %d chunks with %d integrity errors.', count, errors)