mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-26 03:09:22 -05:00
Ensure that all config options have sensible defaults
This will enable us to skip the unintuitive behaviour where the generated config and default config are the same thing.
This commit is contained in:
parent
cf7aef1114
commit
7c2f8881a9
@ -354,8 +354,8 @@ class Config(object):
|
||||
config_file.write("# vim:ft=yaml\n\n")
|
||||
config_file.write(config_str)
|
||||
|
||||
config = yaml.safe_load(config_str)
|
||||
obj.invoke_all("generate_files", config)
|
||||
config_dict = yaml.safe_load(config_str)
|
||||
obj.generate_missing_files(config_dict, config_dir_path)
|
||||
|
||||
print(
|
||||
(
|
||||
@ -390,7 +390,7 @@ class Config(object):
|
||||
)
|
||||
|
||||
if generate_missing_configs:
|
||||
obj.generate_missing_files(config_dict)
|
||||
obj.generate_missing_files(config_dict, config_dir_path)
|
||||
return None
|
||||
|
||||
obj.parse_config_dict(
|
||||
@ -466,8 +466,8 @@ class Config(object):
|
||||
data_dir_path=data_dir_path,
|
||||
)
|
||||
|
||||
def generate_missing_files(self, config_dict):
|
||||
self.invoke_all("generate_files", config_dict)
|
||||
def generate_missing_files(self, config_dict, config_dir_path):
|
||||
self.invoke_all("generate_files", config_dict, config_dir_path)
|
||||
|
||||
|
||||
def find_config_files(search_paths):
|
||||
|
@ -65,13 +65,18 @@ class TrustedKeyServer(object):
|
||||
|
||||
|
||||
class KeyConfig(Config):
|
||||
def read_config(self, config, **kwargs):
|
||||
def read_config(self, config, config_dir_path, **kwargs):
|
||||
# the signing key can be specified inline or in a separate file
|
||||
if "signing_key" in config:
|
||||
self.signing_key = read_signing_keys([config["signing_key"]])
|
||||
else:
|
||||
self.signing_key_path = config["signing_key_path"]
|
||||
self.signing_key = self.read_signing_key(self.signing_key_path)
|
||||
signing_key_path = config.get("signing_key_path")
|
||||
if signing_key_path is None:
|
||||
signing_key_path = os.path.join(
|
||||
config_dir_path, config["server_name"] + ".signing.key"
|
||||
)
|
||||
|
||||
self.signing_key = self.read_signing_key(signing_key_path)
|
||||
|
||||
self.old_signing_keys = self.read_old_signing_keys(
|
||||
config.get("old_signing_keys", {})
|
||||
@ -237,8 +242,15 @@ class KeyConfig(Config):
|
||||
)
|
||||
return keys
|
||||
|
||||
def generate_files(self, config):
|
||||
signing_key_path = config["signing_key_path"]
|
||||
def generate_files(self, config, config_dir_path):
|
||||
if "signing_key" in config:
|
||||
return
|
||||
|
||||
signing_key_path = config.get("signing_key_path")
|
||||
if signing_key_path is None:
|
||||
signing_key_path = os.path.join(
|
||||
config_dir_path, config["server_name"] + ".signing.key"
|
||||
)
|
||||
|
||||
if not self.path_exists(signing_key_path):
|
||||
print("Generating signing key file %s" % (signing_key_path,))
|
||||
|
@ -133,7 +133,7 @@ class LoggingConfig(Config):
|
||||
help="Do not redirect stdout/stderr to the log",
|
||||
)
|
||||
|
||||
def generate_files(self, config):
|
||||
def generate_files(self, config, config_dir_path):
|
||||
log_config = config.get("log_config")
|
||||
if log_config and not os.path.exists(log_config):
|
||||
log_file = self.abspath("homeserver.log")
|
||||
|
@ -91,7 +91,9 @@ class ContentRepositoryConfig(Config):
|
||||
self.max_image_pixels = self.parse_size(config.get("max_image_pixels", "32M"))
|
||||
self.max_spider_size = self.parse_size(config.get("max_spider_size", "10M"))
|
||||
|
||||
self.media_store_path = self.ensure_directory(config["media_store_path"])
|
||||
self.media_store_path = self.ensure_directory(
|
||||
config.get("media_store_path", "media_store")
|
||||
)
|
||||
|
||||
backup_media_store_path = config.get("backup_media_store_path")
|
||||
|
||||
@ -148,7 +150,7 @@ class ContentRepositoryConfig(Config):
|
||||
(provider_class, parsed_config, wrapper_config)
|
||||
)
|
||||
|
||||
self.uploads_path = self.ensure_directory(config["uploads_path"])
|
||||
self.uploads_path = self.ensure_directory(config.get("uploads_path", "uploads"))
|
||||
self.dynamic_thumbnails = config.get("dynamic_thumbnails", False)
|
||||
self.thumbnail_requirements = parse_thumbnail_requirements(
|
||||
config.get("thumbnail_sizes", DEFAULT_THUMBNAIL_SIZES)
|
||||
|
Loading…
Reference in New Issue
Block a user