diff --git a/config.py b/config.py index 8aa283f..36f8033 100644 --- a/config.py +++ b/config.py @@ -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): diff --git a/main.py b/main.py index 55f0936..d353b2a 100644 --- a/main.py +++ b/main.py @@ -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, )