Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix gzip tar extraction by buffering decompressed bytes (#54696)
Riccardo Strinabd5fa34056a6
diff --git a/crates/extension_host/src/wasm_host/wit/since_v0_1_0.rs b/crates/extension_host/src/wasm_host/wit/since_v0_1_0.rsindex 4cd034d4d6a..fca4dca2459 100644--- a/crates/extension_host/src/wasm_host/wit/since_v0_1_0.rs+++ b/crates/extension_host/src/wasm_host/wit/since_v0_1_0.rs@@ -531,7 +531,7 @@ impl ExtensionImports for WasmState {"download failed with status {}",response.status());- let body = BufReader::new(response.body_mut());+ let mut body = BufReader::new(response.body_mut());match file_type {DownloadedFileType::Uncompressed => {@@ -550,11 +550,14 @@ impl ExtensionImports for WasmState {.await?;}DownloadedFileType::GzipTar => {- let body = GzipDecoder::new(body);- futures::pin_mut!(body);+ let mut tar_gz_bytes = Vec::new();+ body.read_to_end(&mut tar_gz_bytes).await?;+ let decompressed_bytes =+ GzipDecoder::new(BufReader::new(tar_gz_bytes.as_slice()));+ futures::pin_mut!(decompressed_bytes);self.host.fs- .extract_tar_file(&destination_path, Archive::new(body))+ .extract_tar_file(&destination_path, Archive::new(decompressed_bytes)).await?;}DownloadedFileType::Zip => {diff --git a/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs b/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rsindex 660ddd9688f..683e69e0870 100644--- a/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs+++ b/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs@@ -1072,7 +1072,7 @@ impl ExtensionImports for WasmState {"download failed with status {}",response.status());- let body = BufReader::new(response.body_mut());+ let mut body = BufReader::new(response.body_mut());match file_type {DownloadedFileType::Uncompressed => {@@ -1091,11 +1091,14 @@ impl ExtensionImports for WasmState {.await?;}DownloadedFileType::GzipTar => {- let body = GzipDecoder::new(body);- futures::pin_mut!(body);+ let mut tar_gz_bytes = Vec::new();+ body.read_to_end(&mut tar_gz_bytes).await?;+ let decompressed_bytes =+ GzipDecoder::new(BufReader::new(tar_gz_bytes.as_slice()));+ futures::pin_mut!(decompressed_bytes);self.host.fs- .extract_tar_file(&destination_path, Archive::new(body))+ .extract_tar_file(&destination_path, Archive::new(decompressed_bytes)).await?;}DownloadedFileType::Zip => {