Refactor configuration access to use latest_arc() instead of latest_ref()

- Updated multiple instances in the codebase to replace calls to latest_ref() with latest_arc() for improved performance and memory management.
- This change affects various modules including validate, enhance, feat (backup, clash, config, profile, proxy, window), utils (draft, i18n, init, network, resolve, server).
- Ensured that all references to configuration data are now using the new arc-based approach to enhance concurrency and reduce cloning overhead.

refactor: update imports to explicitly include ClashInfo and Config in command files
This commit is contained in:
Tunglies
2025-11-04 06:06:20 +08:00
parent 48a19f99e2
commit 2287ea5f0b
37 changed files with 533 additions and 331 deletions
+8 -8
View File
@@ -1,5 +1,9 @@
use super::CmdResult;
use crate::{cmd::StringifyErr, config::*, core, feat};
use crate::{
cmd::StringifyErr,
config::{Config, IVerge},
core, feat,
};
use reqwest_dav::list_cmd::ListFile;
use smartstring::alias::String;
@@ -12,15 +16,11 @@ pub async fn save_webdav_config(url: String, username: String, password: String)
webdav_password: Some(password),
..IVerge::default()
};
Config::verge().await.draft_mut().patch_config(&patch);
Config::verge().await.edit_draft(|e| e.patch_config(&patch));
Config::verge().await.apply();
// 分离数据获取和异步调用
let verge_data = Config::verge().await.latest_ref().clone();
verge_data
.save_file()
.await
.map_err(|err| err.to_string())?;
let verge_data = Config::verge().await.latest_arc();
verge_data.save_file().await.stringify_err()?;
core::backup::WebDavClient::global().reset();
Ok(())
}