From 4fa44f75107362a17d53cfa2b179a1bf36d47ac8 Mon Sep 17 00:00:00 2001 From: Maze Date: Sat, 29 Jan 2022 22:35:07 +0100 Subject: [PATCH] Add missing environmental variable checks Encryption keys, themes and general config dir (if used) were stored in the default directories even if Moment-specific environmental variables were present. --- src/backend/backend.py | 9 +++++++-- src/backend/matrix_client.py | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/backend.py b/src/backend/backend.py index a540326b..e4ea2362 100644 --- a/src/backend/backend.py +++ b/src/backend/backend.py @@ -430,11 +430,16 @@ class Backend: # General functions async def get_config_dir(self) -> Path: - return Path(self.appdirs.user_config_dir) + return Path( + os.environ.get("MOMENT_CONFIG_DIR") or + self.appdirs.user_config_dir, + ) async def get_theme_dir(self) -> Path: - path = Path(self.appdirs.user_data_dir) / "themes" + path = Path( + os.environ.get("MOMENT_DATA_DIR") or self.appdirs.user_data_dir, + ) / "themes" path.mkdir(parents=True, exist_ok=True) return path diff --git a/src/backend/matrix_client.py b/src/backend/matrix_client.py index 0541656f..49ee1836 100644 --- a/src/backend/matrix_client.py +++ b/src/backend/matrix_client.py @@ -165,7 +165,10 @@ class MatrixClient(nio.AsyncClient): device_id: Optional[str] = None, ) -> None: - store = Path(backend.appdirs.user_data_dir) / "encryption" + store = Path( + os.environ.get("MOMENT_DATA_DIR") or backend.appdirs.user_data_dir, + ) / "encryption" + store.mkdir(parents=True, exist_ok=True) proxy: Optional[str]