From 5e15d598ceb28f5c190f9277025757d0f82eef50 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 30 May 2024 10:56:14 +0100 Subject: [PATCH] Close the file before trying to read file size --- synapse/media/media_repository.py | 5 +++++ 1 file changed, 5 insertions(+) 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