Skip to content

Commit f5f37f4

Browse files
committed
fix: avoid downgrade in non-interactive mode
fix: reinstalling same version is not counted as downgrading.
1 parent 70c5be5 commit f5f37f4

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/command_selfupdate.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,22 @@ pub fn run_command_selfupdate(paths: &GlobalPaths) -> Result<()> {
4646

4747
let version = download_juliaup_version(&version_url.to_string())?;
4848

49-
// TODO: how to deal with automatic background updates?
50-
if version <= get_own_version().unwrap() && std::io::stdin().is_terminal() {
51-
eprintln!(
52-
"You are trying to install version: {}-{}, but the currently installed version is newer (or the same)",
53-
juliaup_channel, version
54-
);
49+
if version < get_own_version().unwrap() {
50+
// If not in iteractive mode, avoid downgrading automatically
51+
if !std::io::stdin().is_terminal() {
52+
return Ok(());
53+
}
5554

55+
eprintln!(
56+
"You are trying to install version: {}-{}, but the currently installed version is newer",
57+
juliaup_channel, version
58+
);
5659
match Confirm::with_theme(&SimpleTheme)
5760
.with_prompt("Do you want to continue?")
5861
.default(false)
5962
.interact()?
6063
{
61-
true => {}
64+
true => {} // continue
6265
false => return Ok(()),
6366
}
6467
}

0 commit comments

Comments
 (0)