summaryrefslogtreecommitdiff
path: root/cli/tools/upgrade.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-09-26 17:52:47 -0400
committerGitHub <noreply@github.com>2023-09-26 17:52:47 -0400
commit91832ce2784b68cfd1d2c322d5f5396256ccf4d7 (patch)
treefcd94568ace573a55e28a245f7e2a4b5a3a0b411 /cli/tools/upgrade.rs
parentcb154d6afa3d260e3b281404155d04806aa2014c (diff)
fix(upgrade): error instead of panic on unzip failure (#20691)
For #20683
Diffstat (limited to 'cli/tools/upgrade.rs')
-rw-r--r--cli/tools/upgrade.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/cli/tools/upgrade.rs b/cli/tools/upgrade.rs
index c0fbb73ce..366cc7fc4 100644
--- a/cli/tools/upgrade.rs
+++ b/cli/tools/upgrade.rs
@@ -491,7 +491,7 @@ pub fn unpack_into_dir(
archive_data: Vec<u8>,
is_windows: bool,
temp_dir: &tempfile::TempDir,
-) -> Result<PathBuf, std::io::Error> {
+) -> Result<PathBuf, AnyError> {
const EXE_NAME: &str = "deno";
let temp_dir_path = temp_dir.path();
let exe_ext = if is_windows { "exe" } else { "" };
@@ -557,9 +557,11 @@ pub fn unpack_into_dir(
})?
.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());
fs::remove_file(&archive_path)?;
Ok(exe_path)