mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-28 17:22:15 +08:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c2bb6cc362 | ||
|
|
cefc0d8c62 | ||
|
|
34607dce55 |
@@ -10,6 +10,8 @@
|
||||
- 修复 代理 页展开分组后不显示最新测速结果,需切换节点才刷新
|
||||
- 修复 代理 在全局模式下无法展开节点组
|
||||
- 修复 自定义 CSS 无法修改编辑器字体和字号的问题
|
||||
- 修复恢复备份的同时修改配置,可能导致配置丢失或错乱的问题
|
||||
- 修复切换规则模式与配置变更并发时可能丢失或错乱的问题
|
||||
|
||||
**🐧 Linux**
|
||||
|
||||
|
||||
@@ -33,6 +33,9 @@ async fn finalize_restored_verge_config(
|
||||
webdav_username: Option<String>,
|
||||
webdav_password: Option<String>,
|
||||
) -> Result<()> {
|
||||
// The lock must cover every restored layer; an unlocked apply races a concurrently staged draft.
|
||||
let config_write = Config::lock_config_write().await;
|
||||
|
||||
// A broken restored `verge.yaml` is a restore failure, not a reason to load defaults.
|
||||
let mut restored = help::read_yaml::<IVerge>(&verge_path()?).await?;
|
||||
restored.webdav_url = webdav_url;
|
||||
@@ -55,14 +58,10 @@ async fn finalize_restored_verge_config(
|
||||
profiles_draft.apply();
|
||||
|
||||
let verge_draft = Config::verge().await;
|
||||
{
|
||||
// Hold the write lock so a concurrent patch cannot stage a draft the proxy write reads.
|
||||
let _config_write = Config::lock_config_write().await;
|
||||
verge_draft.edit_draft(|d| {
|
||||
*d = restored.clone();
|
||||
});
|
||||
verge_draft.apply();
|
||||
}
|
||||
verge_draft.edit_draft(|d| {
|
||||
*d = restored.clone();
|
||||
});
|
||||
verge_draft.apply();
|
||||
|
||||
// Turn it off here; a failing core side effect below would otherwise skip this step.
|
||||
if !restored.enable_system_proxy.unwrap_or_default() {
|
||||
@@ -80,6 +79,9 @@ async fn finalize_restored_verge_config(
|
||||
}
|
||||
}
|
||||
|
||||
// `patch_verge` re-acquires the lock through `try_lock_config_write`.
|
||||
drop(config_write);
|
||||
|
||||
// Run configuration side effects without rewriting the already-restored file.
|
||||
if let Err(err) = super::patch_verge(&restored, true).await {
|
||||
logging!(error, Type::Backup, "Failed to apply restored verge config: {err:#}");
|
||||
@@ -146,10 +148,18 @@ async fn restore_backup_archive(path: PathBuf) -> Result<()> {
|
||||
)
|
||||
};
|
||||
|
||||
let file = AsyncHandler::spawn_blocking(move || std::fs::File::open(&path)).await??;
|
||||
let mut zip = zip::ZipArchive::new(file)?;
|
||||
let home_dir = app_home_dir()?;
|
||||
AsyncHandler::spawn_blocking(move || -> Result<()> {
|
||||
let file = std::fs::File::open(&path)?;
|
||||
let mut zip = zip::ZipArchive::new(file)?;
|
||||
zip.extract(&home_dir)?;
|
||||
Ok(())
|
||||
})
|
||||
.await
|
||||
.map_err(|join| anyhow!("backup extraction task failed: {join}"))??;
|
||||
|
||||
// Held for the config-data transition only; extraction is plain filesystem work.
|
||||
let _profile_write = crate::config::profiles::PROFILE_WRITE_LOCK.lock().await;
|
||||
zip.extract(app_home_dir()?)?;
|
||||
finalize_restored_verge_config(webdav_url, webdav_username, webdav_password).await
|
||||
}
|
||||
|
||||
|
||||
@@ -67,11 +67,14 @@ pub async fn change_clash_mode(mode: String) -> Result<(), String> {
|
||||
}
|
||||
|
||||
let clash = Config::clash().await;
|
||||
clash.edit_draft(|d| d.patch_config(&mapping));
|
||||
clash.apply();
|
||||
|
||||
let clash_data = clash.data_arc();
|
||||
if clash_data.save_config().await.is_ok() {
|
||||
// Serialize with patch transactions: an unlocked commit can flush a staged draft mid-rollback.
|
||||
let save_result = {
|
||||
let _config_write = Config::lock_config_write().await;
|
||||
clash.edit_draft(|d| d.patch_config(&mapping));
|
||||
clash.apply();
|
||||
clash.data_arc().save_config().await
|
||||
};
|
||||
if save_result.is_ok() {
|
||||
announce(Refresh::Clash);
|
||||
tray::Tray::global().update_menu_and_icon().await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user