From 03470699d3ae893ec788dedecec953ec365439f9 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Wed, 24 Apr 2019 11:38:13 -0400 Subject: [PATCH] ignore json parsing errors when loading link jsons --- archivebox/legacy/storage/json.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/archivebox/legacy/storage/json.py b/archivebox/legacy/storage/json.py index 282f5c91..2ec56fbf 100644 --- a/archivebox/legacy/storage/json.py +++ b/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