summary refs log tree commit diff
path: root/synapse/media/url_previewer.py
diff options
context:
space:
mode:
authorErik Johnston <erikj@element.io>2024-05-29 11:14:42 +0100
committerGitHub <noreply@github.com>2024-05-29 11:14:42 +0100
commitbb5a692946e69c7f3686f1cb3fc0833b736f066a (patch)
tree6fccac75d6c8b4205d5eb1129a2e17003d60aeaf /synapse/media/url_previewer.py
parentMerge branch 'master' into develop (diff)
downloadsynapse-bb5a692946e69c7f3686f1cb3fc0833b736f066a.tar.xz
Fix slipped logging context when media rejected (#17239)
When a module rejects a piece of media we end up trying to close the
same logging context twice.

Instead of fixing the existing code we refactor to use an async context
manager, which is easier to write correctly.
Diffstat (limited to 'synapse/media/url_previewer.py')
-rw-r--r--synapse/media/url_previewer.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/synapse/media/url_previewer.py b/synapse/media/url_previewer.py
index 3897823b35..2e65a04789 100644
--- a/synapse/media/url_previewer.py
+++ b/synapse/media/url_previewer.py
@@ -592,7 +592,7 @@ class UrlPreviewer:
 
         file_info = FileInfo(server_name=None, file_id=file_id, url_cache=True)
 
-        with self.media_storage.store_into_file(file_info) as (f, fname, finish):
+        async with self.media_storage.store_into_file(file_info) as (f, fname):
             if url.startswith("data:"):
                 if not allow_data_urls:
                     raise SynapseError(
@@ -603,8 +603,6 @@ class UrlPreviewer:
             else:
                 download_result = await self._download_url(url, f)
 
-            await finish()
-
         try:
             time_now_ms = self.clock.time_msec()