diff options
author | Mark Haines <mjark@negativecurvature.net> | 2015-05-01 14:04:39 +0100 |
---|---|---|
committer | Mark Haines <mjark@negativecurvature.net> | 2015-05-01 14:04:39 +0100 |
commit | 7b50769eb95e61e9ae85ad46e5a387a64b68a3a7 (patch) | |
tree | f98784f34d5f0246aee6fcec7fabba20cd8cb27f /synapse/config/repository.py | |
parent | No id field on user (diff) | |
parent | Allow generate-config to run against an existing config file to generate defa... (diff) | |
download | synapse-7b50769eb95e61e9ae85ad46e5a387a64b68a3a7.tar.xz |
Merge pull request #136 from matrix-org/markjh/config_cleanup
Config restructuring.
Diffstat (limited to 'synapse/config/repository.py')
-rw-r--r-- | synapse/config/repository.py | 42 |
1 files changed, 15 insertions, 27 deletions
diff --git a/synapse/config/repository.py b/synapse/config/repository.py index e1827f05e4..adaf4e4bb2 100644 --- a/synapse/config/repository.py +++ b/synapse/config/repository.py @@ -17,32 +17,20 @@ from ._base import Config class ContentRepositoryConfig(Config): - def __init__(self, args): - super(ContentRepositoryConfig, self).__init__(args) - self.max_upload_size = self.parse_size(args.max_upload_size) - self.max_image_pixels = self.parse_size(args.max_image_pixels) - self.media_store_path = self.ensure_directory(args.media_store_path) + def read_config(self, config): + self.max_upload_size = self.parse_size(config["max_upload_size"]) + self.max_image_pixels = self.parse_size(config["max_image_pixels"]) + self.media_store_path = self.ensure_directory(config["media_store_path"]) - def parse_size(self, string): - sizes = {"K": 1024, "M": 1024 * 1024} - size = 1 - suffix = string[-1] - if suffix in sizes: - string = string[:-1] - size = sizes[suffix] - return int(string) * size + def default_config(self, config_dir_path, server_name): + media_store = self.default_path("media_store") + return """ + # Directory where uploaded images and attachments are stored. + media_store_path: "%(media_store)s" - @classmethod - def add_arguments(cls, parser): - super(ContentRepositoryConfig, cls).add_arguments(parser) - db_group = parser.add_argument_group("content_repository") - db_group.add_argument( - "--max-upload-size", default="10M" - ) - db_group.add_argument( - "--media-store-path", default=cls.default_path("media_store") - ) - db_group.add_argument( - "--max-image-pixels", default="32M", - help="Maximum number of pixels that will be thumbnailed" - ) + # The largest allowed upload size in bytes + max_upload_size: "10M" + + # Maximum number of pixels that will be thumbnailed + max_image_pixels: "32M" + """ % locals() |