diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2020-09-09 12:59:41 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-09 12:59:41 -0400 |
commit | b312769c0ee2c40b1a26a6ed39ea1c8a462d4349 (patch) | |
tree | a95ead1bc09492d00fa7ce748d81de5cca4cb4b1 /synapse/rest/media/v1/thumbnail_resource.py | |
parent | Remove some unused distributor signals (#8216) (diff) | |
download | synapse-b312769c0ee2c40b1a26a6ed39ea1c8a462d4349.tar.xz |
Do not error when thumbnailing invalid files (#8236)
If a file cannot be thumbnailed for some reason (e.g. the file is empty), then catch the exception and convert it to a reasonable error message for the client.
Diffstat (limited to 'synapse/rest/media/v1/thumbnail_resource.py')
-rw-r--r-- | synapse/rest/media/v1/thumbnail_resource.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/synapse/rest/media/v1/thumbnail_resource.py b/synapse/rest/media/v1/thumbnail_resource.py index a83535b97b..30421b663a 100644 --- a/synapse/rest/media/v1/thumbnail_resource.py +++ b/synapse/rest/media/v1/thumbnail_resource.py @@ -16,6 +16,7 @@ import logging +from synapse.api.errors import SynapseError from synapse.http.server import DirectServeJsonResource, set_cors_headers from synapse.http.servlet import parse_integer, parse_string @@ -173,7 +174,7 @@ class ThumbnailResource(DirectServeJsonResource): await respond_with_file(request, desired_type, file_path) else: logger.warning("Failed to generate thumbnail") - respond_404(request) + raise SynapseError(400, "Failed to generate thumbnail.") async def _select_or_generate_remote_thumbnail( self, @@ -235,7 +236,7 @@ class ThumbnailResource(DirectServeJsonResource): await respond_with_file(request, desired_type, file_path) else: logger.warning("Failed to generate thumbnail") - respond_404(request) + raise SynapseError(400, "Failed to generate thumbnail.") async def _respond_remote_thumbnail( self, request, server_name, media_id, width, height, method, m_type |