Fix encryption toggling

This commit is contained in:
Andrew Morgan 2020-02-24 23:56:09 +00:00
parent cb95ae83c6
commit 6b7224a61e
2 changed files with 9 additions and 6 deletions

View file

@ -45,6 +45,13 @@ class Config(object):
self.database_filepath = self._get_cfg(["storage", "database_filepath"], required=True)
self.store_filepath = self._get_cfg(["storage", "store_filepath"], required=True)
# Create the store folder if it doesn't exist
if not os.path.isdir(self.store_filepath):
if not os.path.exists(self.store_filepath):
os.mkdir(self.store_filepath)
else:
raise ConfigError(f"storage.store_filepath '{self.store_filepath}' is not a directory")
# Matrix bot account setup
self.user_id = self._get_cfg(["matrix", "user_id"], required=True)
if not re.match("@.*:.*", self.user_id):

View file

@ -34,19 +34,15 @@ async def main():
max_limit_exceeded=0,
max_timeouts=0,
store_sync_tokens=True,
encryption_enabled=config.enable_encryption,
)
# Initialize the matrix client
if config.enable_encryption:
store_path = config.store_filepath
else:
store_path = None
client = AsyncClient(
config.homeserver_url,
config.user_id,
device_id=config.device_id,
store_path=store_path,
store_path=config.store_filepath,
config=client_config,
)