summary refs log tree commit diff
path: root/synapse/rest/media
diff options
context:
space:
mode:
authorAmber Brown <hawkowl@atleastfornow.net>2019-08-13 21:49:28 +1000
committerGitHub <noreply@github.com>2019-08-13 21:49:28 +1000
commit0b6fbb28a858f56766c77eedede7d1dade9e9b1c (patch)
tree57915f5d49e201849c2656d05ec00b7a0f58e9a8 /synapse/rest/media
parentMerge pull request #5836 from matrix-org/erikj/lower_bound_ttl_well_known (diff)
downloadsynapse-0b6fbb28a858f56766c77eedede7d1dade9e9b1c.tar.xz
Don't load the media repo when configured to use an external media repo (#5754)
Diffstat (limited to 'synapse/rest/media')
-rw-r--r--synapse/rest/media/v1/media_repository.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/synapse/rest/media/v1/media_repository.py b/synapse/rest/media/v1/media_repository.py
index 92beefa176..cf5759e9a6 100644
--- a/synapse/rest/media/v1/media_repository.py
+++ b/synapse/rest/media/v1/media_repository.py
@@ -33,6 +33,7 @@ from synapse.api.errors import (
     RequestSendFailed,
     SynapseError,
 )
+from synapse.config._base import ConfigError
 from synapse.logging.context import defer_to_thread
 from synapse.metrics.background_process_metrics import run_as_background_process
 from synapse.util.async_helpers import Linearizer
@@ -753,8 +754,11 @@ class MediaRepositoryResource(Resource):
     """
 
     def __init__(self, hs):
-        Resource.__init__(self)
+        # If we're not configured to use it, raise if we somehow got here.
+        if not hs.config.can_load_media_repo:
+            raise ConfigError("Synapse is not configured to use a media repo.")
 
+        super().__init__()
         media_repo = hs.get_media_repository()
 
         self.putChild(b"upload", UploadResource(hs, media_repo))