From e2155a9e40b9322812a029ed0460204e629cf35c Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Wed, 30 Oct 2024 15:50:41 -0600 Subject: [PATCH] Fail download if download fails (#19990) Co-Authored-By: Mikayla Release Notes: - Remoting: Fixes a bug where we could cache an HTML error page as a binary Co-authored-by: Mikayla --- crates/auto_update/src/auto_update.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/auto_update/src/auto_update.rs b/crates/auto_update/src/auto_update.rs index fbbd23907a71534fabaa4f600e95f48ba2bbca47..be0c1b40a3c2dddf3d3160b98f3039e5867c011e 100644 --- a/crates/auto_update/src/auto_update.rs +++ b/crates/auto_update/src/auto_update.rs @@ -686,6 +686,12 @@ async fn download_remote_server_binary( let request_body = AsyncBody::from(serde_json::to_string(&update_request_body)?); let mut response = client.get(&release.url, request_body, true).await?; + if !response.status().is_success() { + return Err(anyhow!( + "failed to download remote server release: {:?}", + response.status() + )); + } smol::io::copy(response.body_mut(), &mut temp_file).await?; smol::fs::rename(&temp, &target_path).await?;