Fix `solana-install init` making unnecessary API requests (#33949)
* Fix `solana-install init` making unnecessary API requests * Add `is_init` check * chore: Move `semver_update_type` to where it's being used
This commit is contained in:
parent
8c69a0ec38
commit
ec0ddc9468
|
@ -968,20 +968,23 @@ pub fn update(config_file: &str, check_only: bool) -> Result<bool, String> {
|
|||
pub fn init_or_update(config_file: &str, is_init: bool, check_only: bool) -> Result<bool, String> {
|
||||
let mut config = Config::load(config_file)?;
|
||||
|
||||
let semver_update_type = if is_init {
|
||||
SemverUpdateType::Fixed
|
||||
} else {
|
||||
SemverUpdateType::Patch
|
||||
};
|
||||
|
||||
let (updated_version, download_url_and_sha256, release_dir) = if let Some(explicit_release) =
|
||||
&config.explicit_release
|
||||
{
|
||||
match explicit_release {
|
||||
ExplicitRelease::Semver(current_release_semver) => {
|
||||
let release_dir = config.release_dir(current_release_semver);
|
||||
if is_init && release_dir.exists() {
|
||||
(current_release_semver.to_owned(), None, release_dir)
|
||||
} else {
|
||||
let progress_bar = new_spinner_progress_bar();
|
||||
progress_bar.set_message(format!("{LOOKING_GLASS}Checking for updates..."));
|
||||
|
||||
let semver_update_type = if is_init {
|
||||
SemverUpdateType::Fixed
|
||||
} else {
|
||||
SemverUpdateType::Patch
|
||||
};
|
||||
let github_release = check_for_newer_github_release(
|
||||
current_release_semver,
|
||||
semver_update_type,
|
||||
|
@ -1023,6 +1026,7 @@ pub fn init_or_update(config_file: &str, is_init: bool, check_only: bool) -> Res
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ExplicitRelease::Channel(release_channel) => {
|
||||
let version_url = release_channel_version_url(release_channel);
|
||||
|
||||
|
|
Loading…
Reference in New Issue