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.
This commit is contained in:
Maze 2022-01-29 22:35:07 +01:00
parent 602dcbf15f
commit 4fa44f7510
2 changed files with 11 additions and 3 deletions

View File

@ -430,11 +430,16 @@ class Backend:
# General functions # General functions
async def get_config_dir(self) -> Path: 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: 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) path.mkdir(parents=True, exist_ok=True)
return path return path

View File

@ -165,7 +165,10 @@ class MatrixClient(nio.AsyncClient):
device_id: Optional[str] = None, device_id: Optional[str] = None,
) -> 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) store.mkdir(parents=True, exist_ok=True)
proxy: Optional[str] proxy: Optional[str]