From 171bbeb69b52a73155acf9d4e4a3c5abec73450f Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Mon, 1 Feb 2021 16:31:29 -0500 Subject: [PATCH] catch exception on import of old index.json into ArchiveResult --- .../core/migrations/0007_archiveresult.py | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/archivebox/core/migrations/0007_archiveresult.py b/archivebox/core/migrations/0007_archiveresult.py index 6abe72c2..29b269f6 100644 --- a/archivebox/core/migrations/0007_archiveresult.py +++ b/archivebox/core/migrations/0007_archiveresult.py @@ -36,8 +36,25 @@ def forwards_func(apps, schema_editor): for extractor in history: for result in history[extractor]: - ArchiveResult.objects.create(extractor=extractor, snapshot=snapshot, cmd=result["cmd"], cmd_version=result["cmd_version"] or 'unknown', - start_ts=result["start_ts"], end_ts=result["end_ts"], status=result["status"], pwd=result["pwd"], output=result["output"] or 'null') + try: + ArchiveResult.objects.create( + extractor=extractor, + snapshot=snapshot, + pwd=result["pwd"], + cmd=result.get("cmd") or [], + cmd_version=result.get("cmd_version") or 'unknown', + start_ts=result["start_ts"], + end_ts=result["end_ts"], + status=result["status"], + output=result.get("output") or 'null', + ) + except Exception as e: + print( + ' ! Skipping import due to missing/invalid index.json:', + out_dir, + e, + '(open an issue with this index.json for help)', + ) def verify_json_index_integrity(snapshot):