From 460d46999f4aa0a0e1f33adfc3344ba36a6be1c4 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Tue, 27 Jan 2026 22:11:06 +0200 Subject: [PATCH] Make Synapse's `enable_local_media_storage` configurable Ref: - https://github.com/spantaleev/matrix-docker-ansible-deploy/pull/4882 - https://github.com/element-hq/synapse/pull/19204 - https://element-hq.github.io/synapse/latest/usage/configuration/config_documentation.html#enable_local_media_storage We default it to `true`, keeping up with upstream and the old behavior. s3-storage-provider users may set `matrix_synapse_enable_local_media_storage` to `false` to disable local file caching. This likely comes at the expense of some performance. For matrix-media-repo users, it likely doesn't matter what this is set to, as for a matrix-media-repo setup, all media-related API endpoints are captured and forwarded to matrix-media-repo (before reaching Synapse). --- roles/custom/matrix-synapse/defaults/main.yml | 5 +++++ .../matrix-synapse/templates/synapse/homeserver.yaml.j2 | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/roles/custom/matrix-synapse/defaults/main.yml b/roles/custom/matrix-synapse/defaults/main.yml index dce41468e..192fa58cd 100644 --- a/roles/custom/matrix-synapse/defaults/main.yml +++ b/roles/custom/matrix-synapse/defaults/main.yml @@ -1092,6 +1092,11 @@ matrix_synapse_workers_media_repository_workers_container_arguments: [] # Adjusting this value manually is generally not necessary. matrix_synapse_enable_media_repo: "{{ not matrix_synapse_ext_media_repo_enabled and (not matrix_synapse_workers_enabled or (matrix_synapse_workers_enabled_list | selectattr('type', 'equalto', 'media_repository') | list | length == 0)) }}" +# matrix_synapse_enable_local_media_storage controls whether the local on-disk media storage provider is enabled in Synapse. +# When disabled, media is stored only in configured `media_storage_providers` and temporary files are used for processing (no local caching). +# Warning: If this option is set to false and no `media_storage_providers` are configured, all media requests will return 404 errors as there will be no storage backend available. +matrix_synapse_enable_local_media_storage: true + # matrix_synapse_enable_authenticated_media controls if authenticated media is enabled. # If enabled all "old" media remains accessible over the legacy endpoints but new media is blocked. # while this option is enabled all media access and downloads have to be done via authenticated endpoints. diff --git a/roles/custom/matrix-synapse/templates/synapse/homeserver.yaml.j2 b/roles/custom/matrix-synapse/templates/synapse/homeserver.yaml.j2 index ff6f7b724..1a601da83 100644 --- a/roles/custom/matrix-synapse/templates/synapse/homeserver.yaml.j2 +++ b/roles/custom/matrix-synapse/templates/synapse/homeserver.yaml.j2 @@ -1035,11 +1035,15 @@ federation_rr_transactions_per_room_per_second: {{ matrix_synapse_federation_rr_ #enable_media_repo: false enable_media_repo: {{ matrix_synapse_enable_media_repo | to_json }} +# Enable the local on-disk media storage provider. +# When disabled, media is stored only in configured media_storage_providers and temporary files are used for processing (no local caching). +# Warning: If this option is set to false and no media_storage_providers are configured, all media requests will return 404 errors as there will be no storage backend available. +enable_local_media_storage: {{ matrix_synapse_enable_local_media_storage | to_json }} + # Enable authenticated media. # enable_authenticated_media blocks access to new media from the legacy endpoints # and freezes the unauthenticated media repo by blocking all downloads that are not using # the new authenticated endpoints. If this option is turned off all media reverts to being considered "old" - enable_authenticated_media: {{ matrix_synapse_enable_authenticated_media | to_json }} # Directory where uploaded images and attachments are stored.