Gracefully handle failing to thumbnail images (#16211)
This commit is contained in:
parent
a2e0d4cd60
commit
3de82bb2af
|
@ -0,0 +1 @@
|
||||||
|
Fix a long-standing bug where uploading images would fail if we could not generate thumbnails for them.
|
|
@ -21,9 +21,14 @@ import os
|
||||||
import sys
|
import sys
|
||||||
from typing import Any, Dict
|
from typing import Any, Dict
|
||||||
|
|
||||||
|
from PIL import ImageFile
|
||||||
|
|
||||||
from synapse.util.rust import check_rust_lib_up_to_date
|
from synapse.util.rust import check_rust_lib_up_to_date
|
||||||
from synapse.util.stringutils import strtobool
|
from synapse.util.stringutils import strtobool
|
||||||
|
|
||||||
|
# Allow truncated JPEG images to be thumbnailed.
|
||||||
|
ImageFile.LOAD_TRUNCATED_IMAGES = True
|
||||||
|
|
||||||
# Check that we're not running on an unsupported Python version.
|
# Check that we're not running on an unsupported Python version.
|
||||||
#
|
#
|
||||||
# Note that we use an (unneeded) variable here so that pyupgrade doesn't nuke the
|
# Note that we use an (unneeded) variable here so that pyupgrade doesn't nuke the
|
||||||
|
|
|
@ -214,7 +214,10 @@ class MediaRepository:
|
||||||
user_id=auth_user,
|
user_id=auth_user,
|
||||||
)
|
)
|
||||||
|
|
||||||
await self._generate_thumbnails(None, media_id, media_id, media_type)
|
try:
|
||||||
|
await self._generate_thumbnails(None, media_id, media_id, media_type)
|
||||||
|
except Exception as e:
|
||||||
|
logger.info("Failed to generate thumbnails: %s", e)
|
||||||
|
|
||||||
return MXCUri(self.server_name, media_id)
|
return MXCUri(self.server_name, media_id)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue