-
Notifications
You must be signed in to change notification settings - Fork 143
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
Do not download self update if it is the same version #576
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly nits, thanks for doing this!
src/file.rs
Outdated
@@ -9,6 +10,21 @@ pub(crate) fn is_executable(file: &Path) -> bool { | |||
file.is_file() && file.metadata().unwrap().permissions().mode() & 0o111 != 0 | |||
} | |||
|
|||
pub(crate) fn get_bin_version(exec_path: &Path) -> Option<Version> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💟
5ac35f5
to
1ddd7ad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, just a couple nits 👍
|
||
#[cfg(unix)] | ||
pub(crate) fn is_executable(file: &Path) -> bool { | ||
file.is_file() && file.metadata().unwrap().permissions().mode() & 0o111 != 0 | ||
} | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
pub(crate) enum BinError { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is much better!
src/ops/fuelup_check.rs
Outdated
info!("{:>4}- {} - Error getting version string", "", plugin); | ||
} | ||
}; | ||
match get_bin_version(plugin_executable) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we can make it even shorter! This function never returns an error, so doesn't need to return an empty result.
fn check_plugin(plugin_executable: &Path, plugin: &str, latest_version: &Version) {
let version_or_err = match get_bin_version(plugin_executable) {
Ok(version) => format_version_comparison(&version, latest_version),
Err(err) => err.to_string()
};
info!("{:>4}- {} - {}", "", plugin, version_or_err);
}
src/ops/fuelup_check.rs
Outdated
match get_bin_version(&component_executable) { | ||
Ok(version) => { | ||
info!( | ||
"{:>2}{} - {}", | ||
"", | ||
bold(&component.name), | ||
format_version_comparison(&version, latest_version) | ||
); | ||
} | ||
Err(_) => error!( | ||
"{:>2}{} - Error getting version string", | ||
"", | ||
bold(&component.name) | ||
), | ||
}; | ||
|
||
Err(e) => { | ||
error!( | ||
"{:>2}{} - Error getting version string: {}", | ||
"", | ||
bold(&component.name), | ||
e.to_string() | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here:
let version_text = match get_bin_version(&component_executable) {
Ok(version) => format_version_comparison(&version, latest_version),
Err(err) => err.to_string(),
};
info!("{:>2}{} - {}", "", bold(&component.name), version_text);
Co-authored-by: Sophie Dankel <[email protected]>
2e1dc98
to
7fe88ff
Compare
Fixes #555
After: