Catch JSON error and retry
This commit is contained in:
parent
845666dd5a
commit
ee61843183
6
app.py
6
app.py
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue