The image associated with an item can change.
This commit is contained in:
		
							parent
							
								
									5868810ddc
								
							
						
					
					
						commit
						3bbb25226b
					
				
							
								
								
									
										8
									
								
								app.py
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								app.py
									
									
									
									
									
								
							| 
						 | 
					@ -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)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue