Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for existing install location #1009

Merged
merged 5 commits into from
Aug 19, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/bin/juliainstaller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,35 @@
}
}

if install_choices.install_location.exists() {
println!("You are trying to install Juliaup into the folder");
println!("`{}`,", install_choices.install_location);

Check failure on line 384 in src/bin/juliainstaller.rs

View workflow job for this annotation

GitHub Actions / check-juliaup (x86_64-apple-darwin)

`PathBuf` doesn't implement `std::fmt::Display`

Check failure on line 384 in src/bin/juliainstaller.rs

View workflow job for this annotation

GitHub Actions / check-juliaup (aarch64-apple-darwin)

`PathBuf` doesn't implement `std::fmt::Display`
println!("but that folder already exists.");

Check warning on line 386 in src/bin/juliainstaller.rs

View workflow job for this annotation

GitHub Actions / Rustfmt Check

Diff in /home/runner/work/juliaup/juliaup/src/bin/juliainstaller.rs
if args.disable_confirmation_prompt {
println!();
println!(
"Please remove the folder or use interactive mode."
);

return Ok(());
} else {
let continue_with_setup = Confirm::with_theme(theme.as_ref())
.with_prompt("Do you want to continue with the installation and overwrite the existing Juliaup installation folder?")
.default(true)
.interact_opt()?;

if !continue_with_setup.unwrap_or(false) {
return Ok(());

Check warning on line 401 in src/bin/juliainstaller.rs

View workflow job for this annotation

GitHub Actions / Rustfmt Check

Diff in /home/runner/work/juliaup/juliaup/src/bin/juliainstaller.rs
}

std::fs::remove_dir_all(install_choices.install_location)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe this is too drastic? A user might have picked a folder where other (legit) stuff is, and then we delete it all. Probably not good... Maybe we just output an error message saying: "select a folder that doesn't exist" or something like that?

.with_context(|| format!("Failed to delete folder `{}`.", install_choices.install_location))?;

Check failure on line 405 in src/bin/juliainstaller.rs

View workflow job for this annotation

GitHub Actions / check-juliaup (x86_64-apple-darwin)

`PathBuf` doesn't implement `std::fmt::Display`

Check failure on line 405 in src/bin/juliainstaller.rs

View workflow job for this annotation

GitHub Actions / check-juliaup (aarch64-apple-darwin)

`PathBuf` doesn't implement `std::fmt::Display`

println!();
}
}

let juliaupselfbin = install_choices.install_location.join("bin");

trace!("Set juliaupselfbin to `{:?}`", juliaupselfbin);
Expand Down
Loading