mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-04-14 05:51:02 +08:00
fix(backup): reload config.yaml and profiles.yaml after restore to avoid stale memory overwrite #5909
Closes #5909
This commit is contained in:
parent
863a80df43
commit
f26abcd2a9
@ -6,6 +6,7 @@
|
|||||||
- 修复 Monaco 编辑器内右键菜单显示异常
|
- 修复 Monaco 编辑器内右键菜单显示异常
|
||||||
- 修复设置代理端口时检查端口占用
|
- 修复设置代理端口时检查端口占用
|
||||||
- 修复 Monaco 编辑器初始化卡 Loading
|
- 修复 Monaco 编辑器初始化卡 Loading
|
||||||
|
- 修复恢复备份时 `config.yaml` / `profiles.yaml` 文件内字段未正确恢复
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary><strong> ✨ 新增功能 </strong></summary>
|
<summary><strong> ✨ 新增功能 </strong></summary>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
config::{Config, IVerge},
|
config::{Config, IClashTemp, IProfiles, IVerge},
|
||||||
core::backup,
|
core::backup,
|
||||||
process::AsyncHandler,
|
process::AsyncHandler,
|
||||||
utils::{
|
utils::{
|
||||||
@ -25,6 +25,7 @@ pub struct LocalBackupFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Load restored verge.yaml from disk, merge back WebDAV creds, save, and sync memory.
|
/// 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(
|
async fn finalize_restored_verge_config(
|
||||||
webdav_url: Option<String>,
|
webdav_url: Option<String>,
|
||||||
webdav_username: Option<String>,
|
webdav_username: Option<String>,
|
||||||
@ -38,6 +39,20 @@ async fn finalize_restored_verge_config(
|
|||||||
restored.webdav_password = webdav_password;
|
restored.webdav_password = webdav_password;
|
||||||
restored.save_file().await?;
|
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;
|
let verge_draft = Config::verge().await;
|
||||||
verge_draft.edit_draft(|d| {
|
verge_draft.edit_draft(|d| {
|
||||||
*d = restored.clone();
|
*d = restored.clone();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user