refactor(migration): run dedupe only during first-time migration; remove startup dedupe

- Remove per-startup dedupe; keep it limited to migration
- Call dedupe at end of migrate_copies_into_config, then write marker
- Avoid unintended changes on every app launch
This commit is contained in:
Jason
2025-09-05 14:48:03 +08:00
parent 837435223a
commit 2dca85c881
2 changed files with 6 additions and 5 deletions

View File

@@ -66,11 +66,6 @@ pub fn run() {
// 确保两个 App 条目存在
config_guard.ensure_app(&app_config::AppType::Claude);
config_guard.ensure_app(&app_config::AppType::Codex);
// 启动去重:名称(忽略大小写)+API Key
let removed = migration::dedupe_config(&mut *config_guard);
if removed > 0 {
log::info!("已去重重复供应商 {} 个", removed);
}
}
// 保存配置

View File

@@ -395,6 +395,12 @@ pub fn migrate_copies_into_config(config: &mut MultiAppConfig) -> Result<bool, S
}
// 标记完成
// 仅在迁移阶段执行一次全量去重(忽略大小写的名称 + API Key
let removed = dedupe_config(config);
if removed > 0 {
log::info!("迁移阶段已去重重复供应商 {} 个", removed);
}
fs::write(&marker, b"done").map_err(|e| format!("写入迁移标记失败: {}", e))?;
Ok(true)
}