The image associated with an item can change.

This commit is contained in:
Edward Betts 2020-03-04 09:07:11 +00:00
parent 5868810ddc
commit 3bbb25226b

8
app.py
View file

@ -312,9 +312,11 @@ def create_claim(artwork_id, depicts_id, token):
def image_with_cache(qid, image_filename, width): def image_with_cache(qid, image_filename, width):
filename = f'cache/{qid}_{width}_image.json' filename = f'cache/{qid}_{width}_image.json'
if os.path.exists(filename): detail = json.load(open(filename)) if os.path.exists(filename) else {}
detail = json.load(open(filename))
else: # The image associated with an item can change.
# If that happens the detail in the cache will be for the wrong file.
if not detail or image_filename not in detail:
detail = commons.image_detail([image_filename], thumbwidth=width) detail = commons.image_detail([image_filename], thumbwidth=width)
json.dump(detail, open(filename, 'w'), indent=2) json.dump(detail, open(filename, 'w'), indent=2)