mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-12-05 05:50:04 +08:00
fix(profile): identify subscriptions that need recovery
This commit is contained in:
@@ -34,11 +34,23 @@ fn profile_import_error(err: &anyhow::Error) -> std::string::String {
|
||||
format!("导入订阅失败: {err:#}")
|
||||
}
|
||||
|
||||
fn profile_command_error(error: anyhow::Error, fallback: Option<&str>) -> super::CommandFailure {
|
||||
if error.is::<crate::config::profile_storage::RecoveryRequired>() {
|
||||
coded_error("PROFILE_RECOVERY_REQUIRED", format_args!("{error:#}"))
|
||||
} else if let Some(code) = fallback {
|
||||
coded_error(code, format_args!("{error:#}"))
|
||||
} else {
|
||||
super::CommandFailure::plain(error)
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn get_profiles() -> CmdResult<SharedDraft<IProfiles>> {
|
||||
let draft = Config::profiles().await;
|
||||
let _guard = crate::config::profile_storage::read().await.stringify_err()?;
|
||||
let _guard = crate::config::profile_storage::read()
|
||||
.await
|
||||
.map_err(|error| profile_command_error(error, None))?;
|
||||
let data = draft.data_arc();
|
||||
Ok(data)
|
||||
}
|
||||
@@ -146,7 +158,7 @@ pub async fn update_profile(index: std::string::String, option: Option<PrfOption
|
||||
feat::update_profile(&index, option.as_ref(), true)
|
||||
.await
|
||||
.inspect_err(|e| logging!(error, Type::Cmd, "update profile failed: {e:#}"))
|
||||
.with_error_code("PROFILE_UPDATE_FAILED")
|
||||
.map_err(|error| profile_command_error(error, Some("PROFILE_UPDATE_FAILED")))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
|
||||
Reference in New Issue
Block a user