From 2d4b407caa8e0b75d70a274579d3c664069c93d0 Mon Sep 17 00:00:00 2001 From: stason200711 <91085195+stason200711@users.noreply.github.com> Date: Thu, 26 Mar 2026 09:55:00 +0300 Subject: [PATCH] Update default_config.py Allow overriding DATA_DIR via environment variable --- contact/ui/default_config.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/contact/ui/default_config.py b/contact/ui/default_config.py index 6b56f57..1ca15d9 100644 --- a/contact/ui/default_config.py +++ b/contact/ui/default_config.py @@ -56,9 +56,13 @@ def _get_config_root(preferred_dir: str, fallback_name: str = ".contact_client") return fallback_dir - -# Pick the root now. -config_root = _get_config_root(parent_dir) +# Allow overriding config root via environment variable +config_root = os.getenv("CONTACT_CONFIG_ROOT") +if config_root: + if not _is_writable_dir(config_root): + raise RuntimeError(f"CONTACT_CONFIG_ROOT={config_root} is not writable") +else: + config_root = _get_config_root(parent_dir) # Paths (derived from the chosen root) json_file_path = os.path.join(config_root, "config.json")