From c8d8964a3334a63adbc457634cda6c13a750b305 Mon Sep 17 00:00:00 2001 From: mxve Date: Sun, 8 Feb 2026 07:53:10 +0100 Subject: [PATCH] check http status code prevent fnaf morphing --- src/http_async.rs | 8 ++++++++ src/self_update.rs | 8 ++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/http_async.rs b/src/http_async.rs index a9b6bc4..a5be464 100644 --- a/src/http_async.rs +++ b/src/http_async.rs @@ -36,6 +36,10 @@ pub async fn download_file_progress( format!("Failed to GET from '{url}'") })?; + if !res.status().is_success() { + return Err(format!("Request failed with status: {}", res.status())); + } + let total_size = res.content_length().unwrap_or(size); debug!("Download size: {}", misc::human_readable_bytes(total_size)); pb.set_length(total_size); @@ -93,6 +97,10 @@ pub async fn get_body(url: &str) -> Result, String> { debug!("{} {url}", res.status()); + if !res.status().is_success() { + return Err(format!("Request failed with status: {}", res.status())); + } + res.bytes() .await .map(|b| b.to_vec()) diff --git a/src/self_update.rs b/src/self_update.rs index 328b59f..24ace1a 100644 --- a/src/self_update.rs +++ b/src/self_update.rs @@ -93,7 +93,7 @@ pub async fn run(update_only: bool, prerelease: Option) { "alterware-launcher.exe" }; - http_async::download_file( + if let Err(e) = http_async::download_file( &format!( "{}/download/{}", github::download_url(GH_OWNER, GH_REPO, None), @@ -102,7 +102,11 @@ pub async fn run(update_only: bool, prerelease: Option) { &file_path, ) .await - .unwrap(); + { + error!("Self-update download failed: {e}"); + crate::println_error!("Self-update failed ({e}), skipping update."); + return; + } if !file_path.exists() { crate::println_error!("Failed to download launcher update.");