mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-04-13 05:20:28 +08:00
feat: enhance profile update handling with manual trigger
This commit is contained in:
parent
7528c238c4
commit
e5dd127bcc
@ -10,4 +10,6 @@
|
||||
<details>
|
||||
<summary><strong> 🚀 优化改进 </strong></summary>
|
||||
|
||||
- 优化订阅错误通知,仅在手动触发时
|
||||
|
||||
</details>
|
||||
|
||||
@ -158,7 +158,7 @@ pub async fn create_profile(item: PrfItem, file_data: Option<String>) -> CmdResu
|
||||
/// 更新配置文件
|
||||
#[tauri::command]
|
||||
pub async fn update_profile(index: String, option: Option<PrfOption>) -> CmdResult {
|
||||
match feat::update_profile(&index, option.as_ref(), true, true).await {
|
||||
match feat::update_profile(&index, option.as_ref(), true, true, true).await {
|
||||
Ok(_) => {
|
||||
let _: () = Config::profiles().await.apply();
|
||||
Ok(())
|
||||
|
||||
@ -430,7 +430,7 @@ impl Timer {
|
||||
let is_current = Config::profiles().await.latest_arc().current.as_ref() == Some(uid);
|
||||
logging!(info, Type::Timer, "配置 {} 是否为当前激活配置: {}", uid, is_current);
|
||||
|
||||
feat::update_profile(uid, None, is_current, false).await
|
||||
feat::update_profile(uid, None, is_current, false, false).await
|
||||
})
|
||||
.await
|
||||
{
|
||||
|
||||
@ -99,6 +99,7 @@ async fn perform_profile_update(
|
||||
url: &String,
|
||||
opt: Option<&PrfOption>,
|
||||
option: Option<&PrfOption>,
|
||||
is_mannual_trigger: bool,
|
||||
) -> Result<bool> {
|
||||
logging!(info, Type::Config, "[订阅更新] 开始下载新的订阅内容");
|
||||
let mut merged_opt = PrfOption::merge(opt, option);
|
||||
@ -173,7 +174,9 @@ async fn perform_profile_update(
|
||||
}
|
||||
}
|
||||
|
||||
handle::Handle::notice_message("update_failed_even_with_clash", format!("{profile_name} - {last_err}"));
|
||||
if is_mannual_trigger {
|
||||
handle::Handle::notice_message("update_failed_even_with_clash", format!("{profile_name} - {last_err}"));
|
||||
}
|
||||
Ok(is_current)
|
||||
}
|
||||
|
||||
@ -182,12 +185,15 @@ pub async fn update_profile(
|
||||
option: Option<&PrfOption>,
|
||||
auto_refresh: bool,
|
||||
ignore_auto_update: bool,
|
||||
is_mannual_trigger: bool,
|
||||
) -> Result<()> {
|
||||
logging!(info, Type::Config, "[订阅更新] 开始更新订阅 {}", uid);
|
||||
let url_opt = should_update_profile(uid, ignore_auto_update).await?;
|
||||
|
||||
let should_refresh = match url_opt {
|
||||
Some((url, opt)) => perform_profile_update(uid, &url, opt.as_ref(), option).await? && auto_refresh,
|
||||
Some((url, opt)) => {
|
||||
perform_profile_update(uid, &url, opt.as_ref(), option, is_mannual_trigger).await? && auto_refresh
|
||||
}
|
||||
None => auto_refresh,
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user