From df14af7337c41097e2c071e9683f1d4e401e9c4a Mon Sep 17 00:00:00 2001 From: LooSheng Date: Sun, 23 Oct 2022 17:22:26 +0800 Subject: [PATCH] fix: The profile is replaced when the request fails. (#246) --- src-tauri/src/data/prfitem.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src-tauri/src/data/prfitem.rs b/src-tauri/src/data/prfitem.rs index 2a01b1d..5e8b432 100644 --- a/src-tauri/src/data/prfitem.rs +++ b/src-tauri/src/data/prfitem.rs @@ -1,5 +1,6 @@ use crate::utils::{config, dirs, help, tmpl}; use anyhow::{bail, Context, Result}; +use reqwest::StatusCode; use serde::{Deserialize, Serialize}; use serde_yaml::Mapping; use std::fs; @@ -213,6 +214,12 @@ impl PrfItem { builder = builder.user_agent(user_agent.unwrap_or(version)); let resp = builder.build()?.get(url).send().await?; + + let status_code = resp.status(); + if !StatusCode::is_success(&status_code) { + bail!("Error requesting remote profile.") + } + let header = resp.headers(); // parse the Subscription Userinfo