reactor: better handling of camoufox management

This commit is contained in:
zhom
2025-12-25 12:07:41 +04:00
parent 7b756be072
commit 0240b18377
3 changed files with 132 additions and 21 deletions
+4 -4
View File
@@ -818,7 +818,7 @@ impl ApiClient {
Ok(filtered_releases)
}
/// Check if a Brave release has compatible assets for the given platform and architecture
/// Check if a Camoufox release has compatible assets for the given platform and architecture
fn has_compatible_camoufox_asset(
&self,
assets: &[crate::browser::GithubAsset],
@@ -835,9 +835,9 @@ impl ApiClient {
_ => return false,
};
// Look for assets matching the pattern: camoufox-{version}-{release}-{os}.{arch}.zip
// Use ends_with for precise matching to avoid false positives
let pattern = format!(".{os_name}.{arch_name}.zip");
// Look for assets matching the pattern: camoufox-{version}-beta.{number}-{os}.{arch}.zip
// The separator before OS is a dash, e.g., camoufox-135.0.1-beta.24-lin.x86_64.zip
let pattern = format!("-{os_name}.{arch_name}.zip");
assets.iter().any(|asset| {
let name = asset.name.to_lowercase();
name.starts_with("camoufox-") && name.ends_with(&pattern)
+4 -2
View File
@@ -310,7 +310,8 @@ impl Downloader {
os: &str,
arch: &str,
) -> Option<String> {
// Camoufox asset naming pattern: camoufox-{version}-{release}-{os}.{arch}.zip
// Camoufox asset naming pattern: camoufox-{version}-beta.{number}-{os}.{arch}.zip
// Example: camoufox-135.0.1-beta.24-lin.x86_64.zip
let (os_name, arch_name) = match (os, arch) {
("windows", "x64") => ("win", "x86_64"),
("windows", "arm64") => ("win", "arm64"),
@@ -322,7 +323,8 @@ impl Downloader {
};
// Use ends_with for precise matching to avoid false positives
let pattern = format!(".{os_name}.{arch_name}.zip");
// The separator before OS is a dash: -lin.x86_64.zip, -mac.arm64.zip, etc.
let pattern = format!("-{os_name}.{arch_name}.zip");
let asset = assets.iter().find(|asset| {
let name = asset.name.to_lowercase();
name.starts_with("camoufox-") && name.ends_with(&pattern)