Catch JSON error and retry
This commit is contained in:
parent
845666dd5a
commit
ee61843183
8
app.py
8
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'
|
filename = f'cache/{cache_name}_images.json'
|
||||||
cache_exists = os.path.exists(filename)
|
cache_exists = os.path.exists(filename)
|
||||||
|
detail = None
|
||||||
if not refresh and cache_exists:
|
if not refresh and cache_exists:
|
||||||
detail = json.load(open(filename))
|
try:
|
||||||
else:
|
detail = json.load(open(filename))
|
||||||
|
except json.decoder.JSONDecodeError:
|
||||||
|
pass
|
||||||
|
if not detail:
|
||||||
try:
|
try:
|
||||||
detail = commons.image_detail(filenames, thumbwidth=thumbwidth)
|
detail = commons.image_detail(filenames, thumbwidth=thumbwidth)
|
||||||
json.dump(detail, open(filename, 'w'), indent=2)
|
json.dump(detail, open(filename, 'w'), indent=2)
|
||||||
|
|
Loading…
Reference in a new issue