mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-04-26 12:22:43 +08:00
fix(windows): restore default home dir resolution to prevent data loss
v3.10.3 introduced HOME env priority on Windows for test isolation, which caused database path to change when HOME differs from USERPROFILE (common in Git/MSYS environments), making providers appear to disappear. Changes: - Use CC_SWITCH_TEST_HOME for test isolation instead of HOME - Add legacy fallback to detect v3.10.3 database location on Windows - Add logging for legacy path detection to aid debugging
This commit is contained in:
@@ -14,6 +14,9 @@ pub fn ensure_test_home() -> &'static Path {
|
||||
let _ = std::fs::remove_dir_all(&base);
|
||||
}
|
||||
std::fs::create_dir_all(&base).expect("create test home");
|
||||
// Windows 上 `dirs::home_dir()` 不受 HOME/USERPROFILE 影响(走 Known Folder API),
|
||||
// 用 CC_SWITCH_TEST_HOME 显式覆盖,以确保测试不会污染真实用户目录。
|
||||
std::env::set_var("CC_SWITCH_TEST_HOME", &base);
|
||||
std::env::set_var("HOME", &base);
|
||||
#[cfg(windows)]
|
||||
std::env::set_var("USERPROFILE", &base);
|
||||
|
||||
Reference in New Issue
Block a user