summary refs log tree commit diff
path: root/synapse/rest/media/v1/filepath.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2017-06-23 11:14:11 +0100
committerErik Johnston <erik@matrix.org>2017-06-23 11:14:11 +0100
commit7fe8ed1787ca0c1f7a4c56aa1c85e486b76f4550 (patch)
treea2bd30b908118a6e9dff04259e7e2b54d6d6b44a /synapse/rest/media/v1/filepath.py
parentMerge pull request #2297 from matrix-org/erikj/user_dir_fix (diff)
downloadsynapse-7fe8ed1787ca0c1f7a4c56aa1c85e486b76f4550.tar.xz
Store URL cache preview downloads seperately
This makes it easier to clear old media out at a later date
Diffstat (limited to 'synapse/rest/media/v1/filepath.py')
-rw-r--r--synapse/rest/media/v1/filepath.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/synapse/rest/media/v1/filepath.py b/synapse/rest/media/v1/filepath.py
index 0137458f71..d92b7ff337 100644
--- a/synapse/rest/media/v1/filepath.py
+++ b/synapse/rest/media/v1/filepath.py
@@ -71,3 +71,21 @@ class MediaFilePaths(object):
             self.base_path, "remote_thumbnail", server_name,
             file_id[0:2], file_id[2:4], file_id[4:],
         )
+
+    def url_cache_filepath(self, media_id):
+        return os.path.join(
+            self.base_path, "url_cache",
+            media_id[0:2], media_id[2:4], media_id[4:]
+        )
+
+    def url_cache_thumbnail(self, media_id, width, height, content_type,
+                            method):
+        top_level_type, sub_type = content_type.split("/")
+        file_name = "%i-%i-%s-%s-%s" % (
+            width, height, top_level_type, sub_type, method
+        )
+        return os.path.join(
+            self.base_path, "url_cache_thumbnails",
+            media_id[0:2], media_id[2:4], media_id[4:],
+            file_name
+        )