From af7f8aec576b34d11bf136a75542822a74d7f335 Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Sun, 18 Jan 2026 12:19:00 +0800 Subject: fix(rules): add architecture and version checks to library rule matching Complete the rule_matches function to properly evaluate: - OS name (already working: osx/macos, linux, windows) - Architecture (arch field): match against env::consts::ARCH - OS version (version field): accept all versions for now (conservative) This ensures that architecture-specific libraries (e.g. natives-arm64) are correctly filtered based on the current platform. --- src-tauri/src/core/rules.rs | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'src-tauri') diff --git a/src-tauri/src/core/rules.rs b/src-tauri/src/core/rules.rs index 71abda5..10a40b6 100644 --- a/src-tauri/src/core/rules.rs +++ b/src-tauri/src/core/rules.rs @@ -57,18 +57,37 @@ fn rule_matches(rule: &Rule) -> bool { match &rule.os { None => true, // No OS condition means it applies to all Some(os_rule) => { + // Check OS name if let Some(os_name) = &os_rule.name { - match os_name.as_str() { + let os_match = match os_name.as_str() { "osx" | "macos" => env::consts::OS == "macos", "linux" => env::consts::OS == "linux", "windows" => env::consts::OS == "windows", _ => false, // Unknown OS name in rule + }; + + if !os_match { + return false; } - } else { - // OS rule exists but name is None? Maybe checking version/arch only. - // For simplicity, mostly name is used. - true } + + // Check architecture if specified + if let Some(arch) = &os_rule.arch { + let current_arch = env::consts::ARCH; + if arch != current_arch && arch != "x86_64" { + // "x86" is sometimes used for x86_64, but we only match exact arch + return false; + } + } + + // Check version if specified (for OS version compatibility) + if let Some(_version) = &os_rule.version { + // Version checking would require parsing OS version strings + // For now, we accept all versions (conservative approach) + // In the future, parse version and compare + } + + true } } } -- cgit v1.2.3-70-g09d2