refactor(config): remove legacy ~/.config/mytoolkit compatibility

This commit is contained in:
Zhengshou Lai
2026-06-04 00:48:25 +08:00
parent 953ea9231d
commit 3a47e6963d
+2 -7
View File
@@ -7,7 +7,6 @@ from pathlib import Path
_MYTOOLKIT_HOME = Path(os.environ.get("MYTOOLKIT_HOME", Path.home() / ".mytoolkit")) _MYTOOLKIT_HOME = Path(os.environ.get("MYTOOLKIT_HOME", Path.home() / ".mytoolkit"))
CONFIG_PATH = _MYTOOLKIT_HOME / "env.json" CONFIG_PATH = _MYTOOLKIT_HOME / "env.json"
_LEGACY_PATH = Path(__file__).parent / "config.json" _LEGACY_PATH = Path(__file__).parent / "config.json"
_LEGACY_CONFIG_DIR = Path.home() / ".config" / "mytoolkit" / "env.json"
class Config: class Config:
@@ -19,14 +18,10 @@ class Config:
self._data = self._load() self._data = self._load()
def _migrate_legacy(self) -> None: def _migrate_legacy(self) -> None:
"""One-shot move of legacy configs into the user config dir.""" """One-shot move of legacy bin/config.json into the user config dir."""
if self._config_path.exists(): if _LEGACY_PATH.exists() and not self._config_path.exists():
return
self._config_path.parent.mkdir(parents=True, exist_ok=True) self._config_path.parent.mkdir(parents=True, exist_ok=True)
if _LEGACY_PATH.exists():
_LEGACY_PATH.rename(self._config_path) _LEGACY_PATH.rename(self._config_path)
elif _LEGACY_CONFIG_DIR.exists():
_LEGACY_CONFIG_DIR.rename(self._config_path)
def _load(self) -> dict: def _load(self) -> dict:
if self._config_path.exists(): if self._config_path.exists():