Catch JSON error and retry

This commit is contained in:
Edward Betts 2020-06-30 16:26:01 +01:00
parent 845666dd5a
commit ee61843183

6
app.py
View file

@ -799,9 +799,13 @@ def get_image_detail_with_cache(items, cache_name, thumbwidth=None, refresh=Fals
filename = f'cache/{cache_name}_images.json'
cache_exists = os.path.exists(filename)
detail = None
if not refresh and cache_exists:
try:
detail = json.load(open(filename))
else:
except json.decoder.JSONDecodeError:
pass
if not detail:
try:
detail = commons.image_detail(filenames, thumbwidth=thumbwidth)
json.dump(detail, open(filename, 'w'), indent=2)