From 2b678ed04d4ed38501c7c5c1db092c307b1a9624 Mon Sep 17 00:00:00 2001 From: zhom <2717306+zhom@users.noreply.github.com> Date: Sat, 7 Jun 2025 06:00:55 +0400 Subject: [PATCH] fix: hide brave releases without zip files for linux --- src-tauri/src/api_client.rs | 19 ++++++--------- src-tauri/src/browser_version_service.rs | 2 +- src-tauri/src/download.rs | 27 +-------------------- src/components/custom-toast.tsx | 30 ++++++++++++------------ 4 files changed, 24 insertions(+), 54 deletions(-) diff --git a/src-tauri/src/api_client.rs b/src-tauri/src/api_client.rs index cbccd6d..17d9e66 100644 --- a/src-tauri/src/api_client.rs +++ b/src-tauri/src/api_client.rs @@ -805,22 +805,17 @@ impl ApiClient { }) || assets.iter().any(|asset| asset.name.ends_with(".dmg")) } "linux" => { - // For Linux, check for architecture-specific packages (prefer ZIP for stable releases) + // For Linux, be strict about architecture matching - only allow assets that explicitly match the current architecture let arch_pattern = if arch == "arm64" { "arm64" } else { "amd64" }; - assets.iter().any(|asset| { + if assets.iter().any(|asset| { let name = asset.name.to_lowercase(); name.contains("linux") && name.contains(arch_pattern) && name.ends_with(".zip") - }) || assets.iter().any(|asset| { - let name = asset.name.to_lowercase(); - name.contains(arch_pattern) && (name.ends_with(".deb") || name.ends_with(".rpm")) - }) || assets.iter().any(|asset| { - let name = asset.name.to_lowercase(); - name.contains("linux") && name.ends_with(".zip") - }) || assets.iter().any(|asset| { - let name = asset.name.to_lowercase(); - name.ends_with(".deb") || name.ends_with(".rpm") - }) + }) { + return true; + } + + false } _ => false, } diff --git a/src-tauri/src/browser_version_service.rs b/src-tauri/src/browser_version_service.rs index 2368d81..1a91c3d 100644 --- a/src-tauri/src/browser_version_service.rs +++ b/src-tauri/src/browser_version_service.rs @@ -1519,7 +1519,7 @@ mod tests { assert!(chromium_info.url.contains("chrome-mac.zip")); assert!(chromium_info.is_archive); - // Test Brave + // Test Brave - Note: Brave uses dynamic URL resolution, so get_download_info provides a template URL let brave_info = service.get_download_info("brave", "v1.81.9").unwrap(); assert_eq!(brave_info.filename, "Brave-Browser-universal.dmg"); assert_eq!(brave_info.url, "https://github.com/brave/brave-browser/releases/download/v1.81.9/Brave-Browser-universal.dmg"); diff --git a/src-tauri/src/download.rs b/src-tauri/src/download.rs index b8c0dd5..b4f4ca0 100644 --- a/src-tauri/src/download.rs +++ b/src-tauri/src/download.rs @@ -195,7 +195,7 @@ impl Downloader { }) } "linux" => { - // For Linux, prefer ZIP files matching architecture (new format for stable releases) + // For Linux, be strict about architecture matching - same logic as has_compatible_brave_asset let arch_pattern = if arch == "arm64" { "arm64" } else { "amd64" }; assets @@ -204,31 +204,6 @@ impl Downloader { let name = asset.name.to_lowercase(); name.contains("linux") && name.contains(arch_pattern) && name.ends_with(".zip") }) - .or_else(|| { - // Fallback to DEB packages - assets.iter().find(|asset| { - let name = asset.name.to_lowercase(); - name.contains(arch_pattern) && name.ends_with(".deb") - }) - }) - .or_else(|| { - // Fallback to any ZIP - assets.iter().find(|asset| { - let name = asset.name.to_lowercase(); - name.contains("linux") && name.ends_with(".zip") - }) - }) - .or_else(|| { - // Fallback to any DEB - assets.iter().find(|asset| asset.name.ends_with(".deb")) - }) - .or_else(|| { - // Last fallback to RPM if no ZIP or DEB found - assets.iter().find(|asset| { - let name = asset.name.to_lowercase(); - name.contains("x86_64") && name.ends_with(".rpm") - }) - }) } _ => None, }; diff --git a/src/components/custom-toast.tsx b/src/components/custom-toast.tsx index b6332de..0fd7c69 100644 --- a/src/components/custom-toast.tsx +++ b/src/components/custom-toast.tsx @@ -116,31 +116,31 @@ type ToastProps = function getToastIcon(type: ToastProps["type"], stage?: string) { switch (type) { case "success": - return ; + return ; case "error": - return ; + return ; case "download": if (stage === "completed") { return ( - + ); } - return ; + return ; case "version-update": return ( - + ); case "fetching": return ( - + ); case "twilight-update": return ( - + ); default: return ( -
+
); } } @@ -151,10 +151,10 @@ export function UnifiedToast(props: ToastProps) { const progress = "progress" in props ? props.progress : undefined; return ( -
+
{getToastIcon(type, stage)}
-

+

{title}

@@ -165,7 +165,7 @@ export function UnifiedToast(props: ToastProps) { stage === "downloading" && (
-

+

{progress.percentage.toFixed(1)}% {progress.speed && ` • ${progress.speed} MB/s`} {progress.eta && ` • ${progress.eta} remaining`} @@ -195,7 +195,7 @@ export function UnifiedToast(props: ToastProps) { }} />

- + {progress.current}/{progress.total}
@@ -211,7 +211,7 @@ export function UnifiedToast(props: ToastProps) { : "Checking for twilight updates..."}

{props.browserName && ( -

+

{props.browserName} • Rolling Release

)} @@ -220,7 +220,7 @@ export function UnifiedToast(props: ToastProps) { {/* Description */} {description && ( -

+

{description}

)} @@ -235,7 +235,7 @@ export function UnifiedToast(props: ToastProps) { )} {stage === "verifying" && (

- Verifying installation... + Verifying browser files...

)} {stage === "downloading (twilight rolling release)" && (