refactor(archive): remove archive on provider switches/updates

- Remove file archiving when switching providers or updating current provider
- Keep archive functionality only for initial migration (one-time operation)
- Retain simple .bak backup for config.json on each save
- Simplify code by removing unnecessary archive operations from daily workflows

This change prevents unlimited archive growth while maintaining data safety through:
1. Initial migration archives for historical data preservation
2. Single .bak file for basic rollback capability
3. All provider configs stored in SSOT (config.json)
This commit is contained in:
Jason
2025-09-05 16:39:12 +08:00
parent ab6be1d510
commit 54003d69e2
3 changed files with 17 additions and 40 deletions

View File

@@ -107,7 +107,16 @@ impl MultiAppConfig {
/// 保存配置到文件
pub fn save(&self) -> Result<(), String> {
let config_path = get_app_config_path();
write_json_file(&config_path, self)
// 先备份旧版(若存在)到 ~/.cc-switch/config.json.bak再写入新内容
if config_path.exists() {
let backup_path = get_app_config_dir().join("config.json.bak");
if let Err(e) = copy_file(&config_path, &backup_path) {
log::warn!("备份 config.json 到 .bak 失败: {}", e);
}
}
write_json_file(&config_path, self)?;
Ok(())
}
/// 获取指定应用的管理器