From aec4a0c3affa750b9a9c12195591216cd9bd6920 Mon Sep 17 00:00:00 2001 From: JorySeverijnse Date: Fri, 19 Dec 2025 18:25:12 +0100 Subject: [PATCH] Fixed not being able to download chromium anymore Made the code a bit more universal so it also downloads the correct packages based on ones specific platform --- src-tauri/src/api_client.rs | 49 +++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/src-tauri/src/api_client.rs b/src-tauri/src/api_client.rs index 2927b77..0345e18 100644 --- a/src-tauri/src/api_client.rs +++ b/src-tauri/src/api_client.rs @@ -900,13 +900,20 @@ impl ApiClient { pub async fn fetch_chromium_latest_version( &self, ) -> Result> { - // Use architecture-aware URL for Chromium - let arch = if cfg!(target_arch = "aarch64") { - "Mac_Arm" - } else { - "Mac" + // Use platform-aware URL for Chromium to match download URL generation + let (os, arch) = Self::get_platform_info(); + let platform_str = match (&os[..], &arch[..]) { + ("windows", "x64") => "Win_x64", + ("windows", "arm64") => "Win_Arm64", + ("linux", "x64") => "Linux_x64", + ("linux", "arm64") => return Err("Chromium doesn't support ARM64 on Linux".into()), + ("macos", "x64") => "Mac", + ("macos", "arm64") => "Mac_Arm", + _ => { + return Err(format!("Unsupported platform/architecture for Chromium: {os}/{arch}").into()) + } }; - let url = format!("{}/{arch}/LAST_CHANGE", self.chromium_api_base); + let url = format!("{}/{platform_str}/LAST_CHANGE", self.chromium_api_base); let version = self .client .get(&url) @@ -1480,14 +1487,19 @@ mod tests { let server = setup_mock_server().await; let client = create_test_client(&server); - let arch = if cfg!(target_arch = "aarch64") { - "Mac_Arm" - } else { - "Mac" + let (os, arch) = ApiClient::get_platform_info(); + let platform_str = match (&os[..], &arch[..]) { + ("windows", "x64") => "Win_x64", + ("windows", "arm64") => "Win_Arm64", + ("linux", "x64") => "Linux_x64", + ("linux", "arm64") => return, + ("macos", "x64") => "Mac", + ("macos", "arm64") => "Mac_Arm", + _ => return, }; Mock::given(method("GET")) - .and(path(format!("/{arch}/LAST_CHANGE"))) + .and(path(format!("/{platform_str}/LAST_CHANGE"))) .respond_with( ResponseTemplate::new(200) .set_body_string("1465660") @@ -1508,14 +1520,19 @@ mod tests { let server = setup_mock_server().await; let client = create_test_client(&server); - let arch = if cfg!(target_arch = "aarch64") { - "Mac_Arm" - } else { - "Mac" + let (os, arch) = ApiClient::get_platform_info(); + let platform_str = match (&os[..], &arch[..]) { + ("windows", "x64") => "Win_x64", + ("windows", "arm64") => "Win_Arm64", + ("linux", "x64") => "Linux_x64", + ("linux", "arm64") => return, + ("macos", "x64") => "Mac", + ("macos", "arm64") => "Mac_Arm", + _ => return, }; Mock::given(method("GET")) - .and(path(format!("/{arch}/LAST_CHANGE"))) + .and(path(format!("/{platform_str}/LAST_CHANGE"))) .respond_with( ResponseTemplate::new(200) .set_body_string("1465660")