From 44d253d2c033bb37831ce6ac9e2e407ed06836b9 Mon Sep 17 00:00:00 2001 From: cuttingedge1109 <53085803+cuttingedge1109@users.noreply.github.com> Date: Mon, 9 Aug 2021 08:29:46 +0200 Subject: [PATCH 1/5] Update the directory name for remote thumbnails --- tests/replication/test_multi_media_repo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/replication/test_multi_media_repo.py b/tests/replication/test_multi_media_repo.py index ffa425328f0d..9cca6be61c7c 100644 --- a/tests/replication/test_multi_media_repo.py +++ b/tests/replication/test_multi_media_repo.py @@ -229,7 +229,7 @@ def _count_remote_media(self) -> int: def _count_remote_thumbnails(self) -> int: """Count the number of files in our remote thumbnails directory.""" path = os.path.join( - self.hs.get_media_repository().primary_base_path, "remote_thumbnail" + self.hs.get_media_repository().primary_base_path, "remote_thumbnails" ) return sum(len(files) for _, _, files in os.walk(path)) From f5329a2eb92a3bb4dd9e3a3f8560840eae23d7c7 Mon Sep 17 00:00:00 2001 From: cuttingedge1109 <53085803+cuttingedge1109@users.noreply.github.com> Date: Mon, 9 Aug 2021 08:42:34 +0200 Subject: [PATCH 2/5] Add changelog --- changelog.d/10556.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/10556.misc diff --git a/changelog.d/10556.misc b/changelog.d/10556.misc new file mode 100644 index 000000000000..a7cbfd1bb883 --- /dev/null +++ b/changelog.d/10556.misc @@ -0,0 +1 @@ +Rename the directory name for remote thumbnails from `remote_thumbnail` to `remote_thumbnails`. From 19874251efd1d3543bcf1762861e42411bc17ad7 Mon Sep 17 00:00:00 2001 From: cuttingedge1109 <53085803+cuttingedge1109@users.noreply.github.com> Date: Mon, 9 Aug 2021 08:46:15 +0200 Subject: [PATCH 3/5] Update filepath.py --- synapse/rest/media/v1/filepath.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/synapse/rest/media/v1/filepath.py b/synapse/rest/media/v1/filepath.py index 09531ebf548d..3680889d268b 100644 --- a/synapse/rest/media/v1/filepath.py +++ b/synapse/rest/media/v1/filepath.py @@ -114,7 +114,7 @@ def remote_media_thumbnail_rel( 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( - "remote_thumbnail", + "remote_thumbnails", server_name, file_id[0:2], file_id[2:4], @@ -133,7 +133,7 @@ def remote_media_thumbnail_rel_legacy( top_level_type, sub_type = content_type.split("/") file_name = "%i-%i-%s-%s" % (width, height, top_level_type, sub_type) return os.path.join( - "remote_thumbnail", + "remote_thumbnails", server_name, file_id[0:2], file_id[2:4], @@ -144,7 +144,7 @@ def remote_media_thumbnail_rel_legacy( def remote_media_thumbnail_dir(self, server_name: str, file_id: str) -> str: return os.path.join( self.base_path, - "remote_thumbnail", + "remote_thumbnails", server_name, file_id[0:2], file_id[2:4], From 0e64b2ba33747eac02b1a37535181f67441423f1 Mon Sep 17 00:00:00 2001 From: cuttingedge1109 Date: Thu, 2 Sep 2021 12:41:22 +0200 Subject: [PATCH 4/5] Revert the code changes and change doc instead --- changelog.d/10556.doc | 1 + changelog.d/10556.misc | 1 - docs/media_repository.md | 2 +- synapse/rest/media/v1/filepath.py | 6 +++--- tests/replication/test_multi_media_repo.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 changelog.d/10556.doc delete mode 100644 changelog.d/10556.misc diff --git a/changelog.d/10556.doc b/changelog.d/10556.doc new file mode 100644 index 000000000000..2ff5b1554c5b --- /dev/null +++ b/changelog.d/10556.doc @@ -0,0 +1 @@ +Change the directory name for remote thumbnails from `remote_thumbnails` to `remote_thumbnail` in media_repository.md file to match the code. \ No newline at end of file diff --git a/changelog.d/10556.misc b/changelog.d/10556.misc deleted file mode 100644 index a7cbfd1bb883..000000000000 --- a/changelog.d/10556.misc +++ /dev/null @@ -1 +0,0 @@ -Rename the directory name for remote thumbnails from `remote_thumbnail` to `remote_thumbnails`. diff --git a/docs/media_repository.md b/docs/media_repository.md index 1bf8f16f557b..99ee8f1ef7ff 100644 --- a/docs/media_repository.md +++ b/docs/media_repository.md @@ -27,4 +27,4 @@ Remote content is cached under `"remote_content"` directory. Each item of remote content is assigned a local `"filesystem_id"` to ensure that the directory structure `"remote_content/server_name/aa/bb/ccccccccdddddddddddd"` is appropriate. Thumbnails for remote content are stored under -`"remote_thumbnails/server_name/..."` +`"remote_thumbnail/server_name/..."` diff --git a/synapse/rest/media/v1/filepath.py b/synapse/rest/media/v1/filepath.py index 3680889d268b..09531ebf548d 100644 --- a/synapse/rest/media/v1/filepath.py +++ b/synapse/rest/media/v1/filepath.py @@ -114,7 +114,7 @@ def remote_media_thumbnail_rel( 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( - "remote_thumbnails", + "remote_thumbnail", server_name, file_id[0:2], file_id[2:4], @@ -133,7 +133,7 @@ def remote_media_thumbnail_rel_legacy( top_level_type, sub_type = content_type.split("/") file_name = "%i-%i-%s-%s" % (width, height, top_level_type, sub_type) return os.path.join( - "remote_thumbnails", + "remote_thumbnail", server_name, file_id[0:2], file_id[2:4], @@ -144,7 +144,7 @@ def remote_media_thumbnail_rel_legacy( def remote_media_thumbnail_dir(self, server_name: str, file_id: str) -> str: return os.path.join( self.base_path, - "remote_thumbnails", + "remote_thumbnail", server_name, file_id[0:2], file_id[2:4], diff --git a/tests/replication/test_multi_media_repo.py b/tests/replication/test_multi_media_repo.py index 9cca6be61c7c..ffa425328f0d 100644 --- a/tests/replication/test_multi_media_repo.py +++ b/tests/replication/test_multi_media_repo.py @@ -229,7 +229,7 @@ def _count_remote_media(self) -> int: def _count_remote_thumbnails(self) -> int: """Count the number of files in our remote thumbnails directory.""" path = os.path.join( - self.hs.get_media_repository().primary_base_path, "remote_thumbnails" + self.hs.get_media_repository().primary_base_path, "remote_thumbnail" ) return sum(len(files) for _, _, files in os.walk(path)) From 6019e2c61cf2cb567d5923d9386d6951db8139b1 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Thu, 2 Sep 2021 14:06:04 +0100 Subject: [PATCH 5/5] Update changelog.d/10556.doc --- changelog.d/10556.doc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/10556.doc b/changelog.d/10556.doc index 2ff5b1554c5b..7526ae11db7b 100644 --- a/changelog.d/10556.doc +++ b/changelog.d/10556.doc @@ -1 +1 @@ -Change the directory name for remote thumbnails from `remote_thumbnails` to `remote_thumbnail` in media_repository.md file to match the code. \ No newline at end of file +Minor fix to the `media_repository` developer documentation. Contributed by @cuttingedge1109. \ No newline at end of file