From 91832ce2784b68cfd1d2c322d5f5396256ccf4d7 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Tue, 26 Sep 2023 17:52:47 -0400 Subject: fix(upgrade): error instead of panic on unzip failure (#20691) For #20683 --- cli/tools/upgrade.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'cli') 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, is_windows: bool, temp_dir: &tempfile::TempDir, -) -> Result { +) -> Result { 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) -- cgit v1.2.3