浏览代码

catch exception on import of old index.json into ArchiveResult

Nick Sweeting 4 年之前
父节点
当前提交
171bbeb69b
共有 1 个文件被更改,包括 19 次插入2 次删除
  1. 19 2
      archivebox/core/migrations/0007_archiveresult.py

+ 19 - 2
archivebox/core/migrations/0007_archiveresult.py

@@ -36,8 +36,25 @@ def forwards_func(apps, schema_editor):
 
 
         for extractor in history:
         for extractor in history:
             for result in history[extractor]:
             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):
 def verify_json_index_integrity(snapshot):