From 8bd9ff0783c26d9ce4d08b396e5620c57eef2e67 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 30 May 2024 11:22:19 +0100 Subject: Ensure we delete media if we reject due to spam check (#17246) Fixes up #17239 We need to keep the spam check within the `try/except` block. Also makes it so that we don't enter the top span twice. Also also ensures that we get the right thumbnail length. --- synapse/media/media_repository.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'synapse/media/media_repository.py') diff --git a/synapse/media/media_repository.py b/synapse/media/media_repository.py index 9da8495950..9c29e09653 100644 --- a/synapse/media/media_repository.py +++ b/synapse/media/media_repository.py @@ -1049,6 +1049,11 @@ class MediaRepository: finally: t_byte_source.close() + # We flush and close the file to ensure that the bytes have + # been written before getting the size. + f.flush() + f.close() + t_len = os.path.getsize(fname) # Write to database -- cgit 1.5.1