fix(backup): reload config.yaml and profiles.yaml after restore to avoid stale memory overwrite #5909

Closes #5909
This commit is contained in:
Slinetrac
2025-12-23 10:55:30 +08:00
parent 863a80df43
commit f26abcd2a9
2 changed files with 17 additions and 1 deletions

View File

@@ -6,6 +6,7 @@
- 修复 Monaco 编辑器内右键菜单显示异常
- 修复设置代理端口时检查端口占用
- 修复 Monaco 编辑器初始化卡 Loading
- 修复恢复备份时 `config.yaml` / `profiles.yaml` 文件内字段未正确恢复
<details>
<summary><strong> ✨ 新增功能 </strong></summary>

View File

@@ -1,5 +1,5 @@
use crate::{
config::{Config, IVerge},
config::{Config, IClashTemp, IProfiles, IVerge},
core::backup,
process::AsyncHandler,
utils::{
@@ -25,6 +25,7 @@ pub struct LocalBackupFile {
}
/// Load restored verge.yaml from disk, merge back WebDAV creds, save, and sync memory.
/// Also reload other restored configs so restarts won't overwrite them.
async fn finalize_restored_verge_config(
webdav_url: Option<String>,
webdav_username: Option<String>,
@@ -38,6 +39,20 @@ async fn finalize_restored_verge_config(
restored.webdav_password = webdav_password;
restored.save_file().await?;
let restored_clash = IClashTemp::new().await;
let clash_draft = Config::clash().await;
clash_draft.edit_draft(|d| {
*d = restored_clash.clone();
});
clash_draft.apply();
let restored_profiles = IProfiles::new().await;
let profiles_draft = Config::profiles().await;
profiles_draft.edit_draft(|d| {
*d = restored_profiles.clone();
});
profiles_draft.apply();
let verge_draft = Config::verge().await;
verge_draft.edit_draft(|d| {
*d = restored.clone();