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:
@@ -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(())
|
||||
}
|
||||
|
||||
/// 获取指定应用的管理器
|
||||
|
||||
Reference in New Issue
Block a user