summary refs log tree commit diff
path: root/synapse/rest/media
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2017-10-13 10:25:01 +0100
committerErik Johnston <erik@matrix.org>2017-10-13 10:25:01 +0100
commit64db043a71238db3f65f575c40f29260b83145be (patch)
tree68f2d3d0b03cea1010db20282c8409494ebe8cda /synapse/rest/media
parentUse make_deferred_yieldable (diff)
downloadsynapse-64db043a71238db3f65f575c40f29260b83145be.tar.xz
Move makedirs to thread
Diffstat (limited to 'synapse/rest/media')
-rw-r--r--synapse/rest/media/v1/media_repository.py3
1 files changed, 1 insertions, 2 deletions
diff --git a/synapse/rest/media/v1/media_repository.py b/synapse/rest/media/v1/media_repository.py
index 5c5020fe9d..72aad221a8 100644
--- a/synapse/rest/media/v1/media_repository.py
+++ b/synapse/rest/media/v1/media_repository.py
@@ -98,6 +98,7 @@ class MediaRepository(object):
 
     @staticmethod
     def _write_file_synchronously(source, fname, close_source=False):
+        MediaRepository._makedirs(fname)
         source.seek(0)  # Ensure we read from the start of the file
         with open(fname, "wb") as f:
             shutil.copyfileobj(source, f)
@@ -120,7 +121,6 @@ class MediaRepository(object):
             string: the file path written to in the primary media store
         """
         fname = os.path.join(self.primary_base_path, path)
-        self._makedirs(fname)
 
         # Write to the main repository
         yield make_deferred_yieldable(
@@ -141,7 +141,6 @@ class MediaRepository(object):
         """
         if self.backup_base_path:
             backup_fname = os.path.join(self.backup_base_path, path)
-            self._makedirs(backup_fname)
 
             # We can either wait for successful writing to the backup repository
             # or write in the background and immediately return