From 86149db6ed21585a0d8d9afc4778f40e12e87035 Mon Sep 17 00:00:00 2001 From: Versun Date: Wed, 1 Jan 2025 06:11:00 +0800 Subject: [PATCH] fix: improve configuration path handling This change modifies the way configuration paths are handled by creating the XDG configuration directory if it does not exist, ensuring that the application can properly utilize the XDG configuration path. --- aicmt/config.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/aicmt/config.py b/aicmt/config.py index 37d7551..e4a15ce 100644 --- a/aicmt/config.py +++ b/aicmt/config.py @@ -49,13 +49,15 @@ def _get_config_paths() -> Optional[str]: 1. Local configuration (./.aicmtrc) 2. XDG configuration ($XDG_CONFIG_HOME/aicmt/.aicmtrc or ~/.config/aicmt/.aicmtrc) """ - + xdg_config_path = _get_xdg_config_home() / "aicmt" config_path = [ Path.cwd() / ".aicmtrc", # Local config - _get_xdg_config_home() / "aicmt" / ".aicmtrc", # XDG config + xdg_config_path / ".aicmtrc", # XDG config Path.home() / ".aicmtrc", # Legacy global config ] + xdg_config_path.mkdir(parents=True, exist_ok=True) + for path in config_path: if path.is_file(): return path