1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00

fix(upgrade): error instead of panic on unzip failure (#20691)

For #20683
This commit is contained in:
David Sherret 2023-09-26 17:52:47 -04:00 committed by GitHub
parent cb154d6afa
commit 91832ce278
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -491,7 +491,7 @@ pub fn unpack_into_dir(
archive_data: Vec<u8>, archive_data: Vec<u8>,
is_windows: bool, is_windows: bool,
temp_dir: &tempfile::TempDir, temp_dir: &tempfile::TempDir,
) -> Result<PathBuf, std::io::Error> { ) -> Result<PathBuf, AnyError> {
const EXE_NAME: &str = "deno"; const EXE_NAME: &str = "deno";
let temp_dir_path = temp_dir.path(); let temp_dir_path = temp_dir.path();
let exe_ext = if is_windows { "exe" } else { "" }; let exe_ext = if is_windows { "exe" } else { "" };
@ -557,9 +557,11 @@ pub fn unpack_into_dir(
})? })?
.wait()? .wait()?
} }
ext => panic!("Unsupported archive type: '{ext}'"), ext => bail!("Unsupported archive type: '{ext}'"),
}; };
assert!(unpack_status.success()); if !unpack_status.success() {
bail!("Failed to unpack archive.");
}
assert!(exe_path.exists()); assert!(exe_path.exists());
fs::remove_file(&archive_path)?; fs::remove_file(&archive_path)?;
Ok(exe_path) Ok(exe_path)