Skip to content

Commit 14b075f

Browse files
committed
fix: run upgrade self installer from temp file
1 parent d140e3c commit 14b075f

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/commands/upgrade.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,21 @@ fn upgrade_self() -> Result<()> {
103103
fs::write(&tmp, script)?;
104104
let mut cmd = std::process::Command::new("powershell");
105105
cmd.arg("-ExecutionPolicy").arg("Bypass").arg("-File").arg(tmp);
106-
cmd.status()?;
106+
let status = cmd.status()?;
107+
if !status.success() {
108+
anyhow::bail!("Failed to upgrade dvm");
109+
}
107110
} else {
108111
let url = "https://raw.githubusercontent.com/justjavac/dvm/main/install.sh";
109112
let script = tinyget::get(url).send()?;
110113
let script = script.as_str()?;
111114
let tmp = tempfile::tempdir()?;
112115
let tmp = tmp.path().join("install.sh");
113-
fs::write(tmp, script)?;
114-
std::process::Command::new("bash").arg(script).status()?;
116+
fs::write(&tmp, script)?;
117+
let status = std::process::Command::new("bash").arg(&tmp).status()?;
118+
if !status.success() {
119+
anyhow::bail!("Failed to upgrade dvm");
120+
}
115121
}
116122
}
117123

0 commit comments

Comments
 (0)