diff options
| author | 2026-01-18 12:19:00 +0800 | |
|---|---|---|
| committer | 2026-01-18 12:19:00 +0800 | |
| commit | af7f8aec576b34d11bf136a75542822a74d7f335 (patch) | |
| tree | 3bfcbc1be137ad3d7ef97ec736b0a66818c4d2a9 | |
| parent | e7d683d79bec482a13c821f8c1da3c8c1d719d1b (diff) | |
| download | DropOut-af7f8aec576b34d11bf136a75542822a74d7f335.tar.gz DropOut-af7f8aec576b34d11bf136a75542822a74d7f335.zip | |
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.
| -rw-r--r-- | src-tauri/src/core/rules.rs | 29 |
1 files changed, 24 insertions, 5 deletions
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 } } } |