Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more exception handling around LevelDB records in case of corruption #78

Merged
merged 1 commit into from
Feb 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions pyhindsight/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,25 @@ def get_ldb_records(ldb_path, prefix=''):

cleaned_records = []

for record in db.iterate_records_raw():
cleaned_record = record.__dict__
try:
for record in db.iterate_records_raw():
cleaned_record = record.__dict__

if record.file_type.name == 'Ldb':
cleaned_record['key'] = record.key[:-8]

if record.file_type.name == 'Ldb':
cleaned_record['key'] = record.key[:-8]
if cleaned_record['key'].startswith(prefix):
cleaned_record['key'] = cleaned_record['key'][len(prefix):]
cleaned_record['state'] = cleaned_record['state'].name
cleaned_record['file_type'] = cleaned_record['file_type'].name

if cleaned_record['key'].startswith(prefix):
cleaned_record['key'] = cleaned_record['key'][len(prefix):]
cleaned_record['state'] = cleaned_record['state'].name
cleaned_record['file_type'] = cleaned_record['file_type'].name
cleaned_records.append(cleaned_record)

cleaned_records.append(cleaned_record)
except ValueError:
log.warning(f' - Exception reading LevelDB: ValueError')

except Exception as e:
log.warning(f' - Exception reading LevelDB: {e}')

db.close()
return cleaned_records
Expand Down