extension: Don't use `unzip` to extract `.zip` files (#13869)

Marshall Bowers created

This PR replaces the usage of `unzip` for extracting `.zip` files
downloaded by extensions with extraction via a library.

This will allow us to extract `.zip` files even if `unzip` is not
available (e.g., on Windows).

Release Notes:

- Removed the need for `unzip` to be present on the system to extract
`.zip` files downloaded by extensions.

Change summary

crates/extension/src/wasm_host/wit/since_v0_0_7.rs | 23 ++-------------
1 file changed, 3 insertions(+), 20 deletions(-)

Detailed changes

crates/extension/src/wasm_host/wit/since_v0_0_7.rs 🔗

@@ -421,27 +421,10 @@ impl ExtensionImports for WasmState {
                         .await?;
                 }
                 DownloadedFileType::Zip => {
-                    let file_name = destination_path
-                        .file_name()
-                        .ok_or_else(|| anyhow!("invalid download path"))?
-                        .to_string_lossy();
-                    let zip_filename = format!("{file_name}.zip");
-                    let mut zip_path = destination_path.clone();
-                    zip_path.set_file_name(zip_filename);
-
                     futures::pin_mut!(body);
-                    self.host.fs.create_file_with(&zip_path, body).await?;
-
-                    let unzip_status = std::process::Command::new("unzip")
-                        .current_dir(&extension_work_dir)
-                        .arg("-d")
-                        .arg(&destination_path)
-                        .arg(&zip_path)
-                        .output()?
-                        .status;
-                    if !unzip_status.success() {
-                        Err(anyhow!("failed to unzip {} archive", path.display()))?;
-                    }
+                    node_runtime::extract_zip(&destination_path, body)
+                        .await
+                        .with_context(|| format!("failed to unzip {} archive", path.display()))?;
                 }
             }