From 142e843a5511b55d761ce10860664d709ad6d8bb Mon Sep 17 00:00:00 2001 From: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> Date: Thu, 3 Nov 2022 22:32:23 +0100 Subject: fix: Resolve thread crash due to block in async (#39) Set the function to async but it was still using blocking version of reqwest. --- src-tauri/src/lib.rs | 6 ++++-- src-tauri/src/main.rs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src-tauri/src') diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 5d8d55e6..416efb64 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -358,18 +358,20 @@ pub fn convert_release_candidate_number(version_number: String) -> String { /// Checks if installed FlightCore version is up-to-date /// false -> FlightCore install is up-to-date /// true -> FlightCore install is outdated -pub fn check_is_flightcore_outdated() -> Result { +pub async fn check_is_flightcore_outdated() -> Result { // Get newest version number from GitHub API println!("Checking GitHub API"); let url = "https://api.github.com/repos/GeckoEidechse/FlightCore/releases/latest"; let user_agent = "GeckoEidechse/FlightCore"; - let client = reqwest::blocking::Client::new(); + let client = reqwest::Client::new(); let res = client .get(url) .header(reqwest::header::USER_AGENT, user_agent) .send() + .await .unwrap() .text() + .await .unwrap(); let json_response: serde_json::Value = diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index a0f502b6..9cc27e31 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -203,7 +203,7 @@ async fn check_is_northstar_outdated( /// false -> FlightCore install is up-to-date /// true -> FlightCore install is outdated async fn check_is_flightcore_outdated_caller() -> Result { - check_is_flightcore_outdated() + check_is_flightcore_outdated().await } #[tauri::command] -- cgit v1.2.3