Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 3d2acc9

Browse files
committed
Return a 404 if we don't have the original file
1 parent 2d57728 commit 3d2acc9

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

synapse/rest/media/v1/media_storage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ async def ensure_media_is_in_local_cache(self, file_info: FileInfo) -> str:
244244
await consumer.wait()
245245
return local_path
246246

247-
raise Exception("file could not be found")
247+
raise NotFoundError()
248248

249249
def _file_info_to_path(self, file_info: FileInfo) -> str:
250250
"""Converts file_info into a relative path.

synapse/rest/media/v1/thumbnail_resource.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,13 @@ async def _select_and_respond_with_thumbnail(
340340
# width/height/method so we can just call the "generate exact"
341341
# methods.
342342

343+
# First let's check that we do actually have the original image
344+
# still. This will throw a 404 if we don't.
345+
# TODO: We should refetch the thumbnails for remote media.
346+
await self.media_storage.ensure_media_is_in_local_cache(
347+
FileInfo(server_name, file_id, url_cache=url_cache)
348+
)
349+
343350
if server_name:
344351
await self.media_repo.generate_remote_exact_thumbnail(
345352
server_name,

0 commit comments

Comments
 (0)