fix(profile): identify subscriptions that need recovery

This commit is contained in:
Tunglies
2026-12-04 07:37:51 +08:00
parent 235a0507f0
commit 70d6917104
25 changed files with 236 additions and 52 deletions
+14 -2
View File
@@ -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]