Skip to content

Commit 142e843

Browse files
fix: Resolve thread crash due to block in async (#39)
Set the function to async but it was still using blocking version of reqwest.
1 parent d8232fa commit 142e843

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src-tauri/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,18 +358,20 @@ pub fn convert_release_candidate_number(version_number: String) -> String {
358358
/// Checks if installed FlightCore version is up-to-date
359359
/// false -> FlightCore install is up-to-date
360360
/// true -> FlightCore install is outdated
361-
pub fn check_is_flightcore_outdated() -> Result<bool, String> {
361+
pub async fn check_is_flightcore_outdated() -> Result<bool, String> {
362362
// Get newest version number from GitHub API
363363
println!("Checking GitHub API");
364364
let url = "https://api.github.com/repos/GeckoEidechse/FlightCore/releases/latest";
365365
let user_agent = "GeckoEidechse/FlightCore";
366-
let client = reqwest::blocking::Client::new();
366+
let client = reqwest::Client::new();
367367
let res = client
368368
.get(url)
369369
.header(reqwest::header::USER_AGENT, user_agent)
370370
.send()
371+
.await
371372
.unwrap()
372373
.text()
374+
.await
373375
.unwrap();
374376

375377
let json_response: serde_json::Value =

src-tauri/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ async fn check_is_northstar_outdated(
203203
/// false -> FlightCore install is up-to-date
204204
/// true -> FlightCore install is outdated
205205
async fn check_is_flightcore_outdated_caller() -> Result<bool, String> {
206-
check_is_flightcore_outdated()
206+
check_is_flightcore_outdated().await
207207
}
208208

209209
#[tauri::command]

0 commit comments

Comments
 (0)