port fixes from https://github.com/modrinth/code/pull/2369/
This commit is contained in:
parent
aecfbad53a
commit
44742fa21f
2 changed files with 20 additions and 7 deletions
|
|
@ -68,7 +68,7 @@ pub fn validate_os_rule(rule: &OsRule, java_arch: &str, updated: bool) -> bool {
|
|||
|
||||
if let Some(name) = &rule.name {
|
||||
if updated && (name != &Os::LinuxArm64 || name != &Os::LinuxArm32) {
|
||||
rule_match &= &Os::native() == name || &Os::native_arch(java_arch) == name;
|
||||
rule_match &= Os::native() == name.get_os() || &Os::native_arch(java_arch) == name;
|
||||
} else {
|
||||
rule_match &= &Os::native_arch(java_arch) == name;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,9 +8,22 @@ pub trait OsExt {
|
|||
|
||||
/// Get the [`Os`] of the current system along with it's arch from the `java_arch`.
|
||||
fn native_arch(java_arch: &str) -> Self;
|
||||
|
||||
/// Gets the OS from an OS + Arch
|
||||
#[must_use]
|
||||
fn get_os(&self) -> Self;
|
||||
}
|
||||
|
||||
impl OsExt for Os {
|
||||
fn native() -> Self {
|
||||
match std::env::consts::OS {
|
||||
"windows" => Self::Windows,
|
||||
"macos" => Self::Osx,
|
||||
"linux" => Self::Linux,
|
||||
_ => Self::Unknown,
|
||||
}
|
||||
}
|
||||
|
||||
fn native_arch(java_arch: &str) -> Self {
|
||||
if std::env::consts::OS == "windows" {
|
||||
if java_arch == "aarch64" {
|
||||
|
|
@ -37,12 +50,12 @@ impl OsExt for Os {
|
|||
}
|
||||
}
|
||||
|
||||
fn native() -> Self {
|
||||
match std::env::consts::OS {
|
||||
"windows" => Self::Windows,
|
||||
"macos" => Self::Osx,
|
||||
"linux" => Self::Linux,
|
||||
_ => Self::Unknown,
|
||||
fn get_os(&self) -> Self {
|
||||
match self {
|
||||
Self::OsxArm64 => Self::Osx,
|
||||
Self::LinuxArm32 | Self::LinuxArm64 => Self::Linux,
|
||||
Self::WindowsArm64 => Self::Windows,
|
||||
_ => self.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue