mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 08:45:41 +08:00
fix: profile auto refresh #5274
This commit is contained in:
@@ -180,7 +180,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, Some(true)).await {
|
||||
match feat::update_profile(index, option, Some(true), Some(true)).await {
|
||||
Ok(_) => Ok(()),
|
||||
Err(e) => {
|
||||
log::error!(target: "app", "{}", e);
|
||||
|
||||
@@ -492,7 +492,7 @@ impl Timer {
|
||||
is_current
|
||||
);
|
||||
|
||||
feat::update_profile(uid.clone(), None, Some(is_current)).await
|
||||
feat::update_profile(uid.clone(), None, Some(is_current), None).await
|
||||
})
|
||||
.await
|
||||
{
|
||||
|
||||
@@ -23,7 +23,10 @@ pub async fn toggle_proxy_profile(profile_index: String) {
|
||||
}
|
||||
}
|
||||
|
||||
async fn should_update_profile(uid: String) -> Result<Option<(String, Option<PrfOption>)>> {
|
||||
async fn should_update_profile(
|
||||
uid: String,
|
||||
ignore_auto_update: bool,
|
||||
) -> Result<Option<(String, Option<PrfOption>)>> {
|
||||
let profiles = Config::profiles().await;
|
||||
let profiles = profiles.latest_ref();
|
||||
let item = profiles.get_item(&uid)?;
|
||||
@@ -35,11 +38,12 @@ async fn should_update_profile(uid: String) -> Result<Option<(String, Option<Prf
|
||||
} else if item.url.is_none() {
|
||||
log::warn!(target: "app", "[订阅更新] {uid} 缺少URL,无法更新");
|
||||
bail!("failed to get the profile item url");
|
||||
} else if !item
|
||||
.option
|
||||
.as_ref()
|
||||
.and_then(|o| o.allow_auto_update)
|
||||
.unwrap_or(true)
|
||||
} else if !ignore_auto_update
|
||||
&& !item
|
||||
.option
|
||||
.as_ref()
|
||||
.and_then(|o| o.allow_auto_update)
|
||||
.unwrap_or(true)
|
||||
{
|
||||
log::info!(target: "app", "[订阅更新] {} 禁止自动更新,跳过更新", uid);
|
||||
Ok(None)
|
||||
@@ -123,11 +127,13 @@ pub async fn update_profile(
|
||||
uid: String,
|
||||
option: Option<PrfOption>,
|
||||
auto_refresh: Option<bool>,
|
||||
ignore_auto_update: Option<bool>,
|
||||
) -> Result<()> {
|
||||
logging!(info, Type::Config, "[订阅更新] 开始更新订阅 {}", uid);
|
||||
let auto_refresh = auto_refresh.unwrap_or(true);
|
||||
let ignore_auto_update = ignore_auto_update.unwrap_or(false);
|
||||
|
||||
let url_opt = should_update_profile(uid.clone()).await?;
|
||||
let url_opt = should_update_profile(uid.clone(), ignore_auto_update).await?;
|
||||
|
||||
let should_refresh = match url_opt {
|
||||
Some((url, opt)) => {
|
||||
|
||||
Reference in New Issue
Block a user