Skip to content

Commit

Permalink
fix: avoid downgrade in non-interactive mode
Browse files Browse the repository at this point in the history
fix: reinstalling same version is not counted as downgrading.
  • Loading branch information
ghyatzo committed Apr 16, 2024
1 parent 70c5be5 commit f5f37f4
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/command_selfupdate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,22 @@ pub fn run_command_selfupdate(paths: &GlobalPaths) -> Result<()> {

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

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

eprintln!(
"You are trying to install version: {}-{}, but the currently installed version is newer",
juliaup_channel, version
);
match Confirm::with_theme(&SimpleTheme)
.with_prompt("Do you want to continue?")
.default(false)
.interact()?
{
true => {}
true => {} // continue
false => return Ok(()),
}
}
Expand Down

0 comments on commit f5f37f4

Please sign in to comment.