Fail download if download fails (#19990)

Conrad Irwin and Mikayla created

Co-Authored-By: Mikayla <mikayla@zed.dev>

Release Notes:

- Remoting: Fixes a bug where we could cache an HTML error page as a
binary

Co-authored-by: Mikayla <mikayla@zed.dev>

Change summary

crates/auto_update/src/auto_update.rs | 6 ++++++
1 file changed, 6 insertions(+)

Detailed changes

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?;