From 837435223ad16413163b15e6ebb848576de86b79 Mon Sep 17 00:00:00 2001 From: Jason Date: Fri, 5 Sep 2025 14:29:16 +0800 Subject: [PATCH] chore(migration): remove legacy copy files after successful archive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - During copies→config migration, delete original legacy files only if archived - Applies to Claude settings-* and Codex auth-*/config-* pairs - Keep archive_file non-destructive for live backups --- src-tauri/src/migration.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src-tauri/src/migration.rs b/src-tauri/src/migration.rs index 809c0ca..35f3f29 100644 --- a/src-tauri/src/migration.rs +++ b/src-tauri/src/migration.rs @@ -1,6 +1,6 @@ use crate::app_config::{AppType, MultiAppConfig}; use crate::config::{ - archive_file, get_app_config_dir, get_app_config_path, get_claude_config_dir, + archive_file, delete_file, get_app_config_dir, get_app_config_path, get_claude_config_dir, }; use serde_json::Value; use std::collections::{HashMap, HashSet}; @@ -370,14 +370,27 @@ pub fn migrate_copies_into_config(config: &mut MultiAppConfig) -> Result { + let _ = delete_file(&p); + } + _ => { + // 归档失败则不要删除原文件,保守处理 + } + } } for (_, ap, cp, _) in codex_items.into_iter() { if let Some(ap) = ap { - let _ = archive_file(ts, "codex", &ap); + match archive_file(ts, "codex", &ap) { + Ok(Some(_)) => { let _ = delete_file(&ap); } + _ => {} + } } if let Some(cp) = cp { - let _ = archive_file(ts, "codex", &cp); + match archive_file(ts, "codex", &cp) { + Ok(Some(_)) => { let _ = delete_file(&cp); } + _ => {} + } } }