mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-12 22:25:44 -04:00
bail out if old index.json is found during init but doesnt contain links
This commit is contained in:
parent
217952c8d0
commit
50b341baab
1 changed files with 13 additions and 1 deletions
|
@ -60,7 +60,19 @@ def parse_json_main_index(out_dir: Path=OUTPUT_DIR) -> Iterator[Link]:
|
||||||
index_path = Path(out_dir) / JSON_INDEX_FILENAME
|
index_path = Path(out_dir) / JSON_INDEX_FILENAME
|
||||||
if index_path.exists():
|
if index_path.exists():
|
||||||
with open(index_path, 'r', encoding='utf-8') as f:
|
with open(index_path, 'r', encoding='utf-8') as f:
|
||||||
links = pyjson.load(f)['links']
|
try:
|
||||||
|
links = pyjson.load(f)['links']
|
||||||
|
if links:
|
||||||
|
Link.from_json(links[0])
|
||||||
|
except Exception as err:
|
||||||
|
print(" {lightyellow}! Found an index.json in the project root but couldn't load links from it: {} {}".format(
|
||||||
|
index_path,
|
||||||
|
err.__class__.__name__,
|
||||||
|
err,
|
||||||
|
**ANSI,
|
||||||
|
))
|
||||||
|
return ()
|
||||||
|
|
||||||
for link_json in links:
|
for link_json in links:
|
||||||
try:
|
try:
|
||||||
yield Link.from_json(link_json)
|
yield Link.from_json(link_json)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue