Răsfoiți Sursa

ignore json parsing errors when loading link jsons

Nick Sweeting 6 ani în urmă
părinte
comite
03470699d3
1 a modificat fișierele cu 5 adăugiri și 2 ștergeri
  1. 5 2
      archivebox/legacy/storage/json.py

+ 5 - 2
archivebox/legacy/storage/json.py

@@ -96,8 +96,11 @@ def parse_json_link_details(out_dir: str) -> Optional[Link]:
     existing_index = os.path.join(out_dir, JSON_INDEX_FILENAME)
     if os.path.exists(existing_index):
         with open(existing_index, 'r', encoding='utf-8') as f:
-            link_json = json.load(f)
-            return Link.from_json(link_json)
+            try:
+                link_json = json.load(f)
+                return Link.from_json(link_json)
+            except json.JSONDecodeError:
+                pass
     return None
 
 @enforce_types