[solana-install-init] Optimize error message for Windows user permission installation (#234)

* feat: check user's permissions in Windows

* feat: Remove check fun and check os_err

* fmt and optimize code
This commit is contained in:
WGB5445 2024-03-18 09:58:28 -07:00 committed by GHA: Update Upstream From Fork
parent 928ede1d49
commit 6846756926
1 changed files with 7 additions and 3 deletions

View File

@ -1171,13 +1171,17 @@ pub fn init_or_update(config_file: &str, is_init: bool, check_only: bool) -> Res
release_dir.join("solana-release"),
config.active_release_dir(),
)
.map_err(|err| {
format!(
.map_err(|err| match err.raw_os_error() {
#[cfg(windows)]
Some(os_err) if os_err == winapi::shared::winerror::ERROR_PRIVILEGE_NOT_HELD => {
"You need to run this command with administrator privileges.".to_string()
}
_ => format!(
"Unable to symlink {:?} to {:?}: {}",
release_dir,
config.active_release_dir(),
err
)
),
})?;
config.save(config_file)?;