From 017523bdace4dc3d581a1940d3ef51a635c3fcea Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Tue, 21 Dec 2021 16:55:03 -0800 Subject: [PATCH] Return 404 if we try to reload_metadata on a missing file. --- .../etiquette_flask/backend/endpoints/photo_endpoints.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py b/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py index 4f555cd..6366fd9 100644 --- a/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py +++ b/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py @@ -5,6 +5,7 @@ import urllib.parse from voussoirkit import cacheclass from voussoirkit import flasktools +from voussoirkit import pathclass from voussoirkit import stringtools import etiquette @@ -176,7 +177,10 @@ def post_photo_refresh_metadata_core(photo_ids): for photo in photos: photo._uncache() photo = common.P_photo(photo.id, response_type='json') - photo.reload_metadata() + try: + photo.reload_metadata() + except pathclass.NotFile: + flask.abort(404) if photo.thumbnail is None: try: photo.generate_thumbnail()