From 467e82ca932c4d31fe07983b36ccd186daaf48a8 Mon Sep 17 00:00:00 2001 From: zhom <2717306+zhom@users.noreply.github.com> Date: Sat, 9 Aug 2025 08:51:36 +0400 Subject: [PATCH] refactor: check for camoufox inside install dir directly --- .vscode/settings.json | 2 ++ src-tauri/src/browser.rs | 18 +++++++----------- src-tauri/src/extraction.rs | 6 ++++++ src-tauri/src/profile/manager.rs | 5 +++++ 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index f260abe..4ce83b9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -25,6 +25,7 @@ "cmdk", "codegen", "codesign", + "commitish", "CTYPE", "daijro", "dataclasses", @@ -178,6 +179,7 @@ "xfconf", "xsettings", "zhom", + "zipball", "zoneinfo" ] } diff --git a/src-tauri/src/browser.rs b/src-tauri/src/browser.rs index 57c87bb..fc5a626 100644 --- a/src-tauri/src/browser.rs +++ b/src-tauri/src/browser.rs @@ -168,7 +168,7 @@ mod linux { install_dir: &Path, browser_type: &BrowserType, ) -> Result> { - // Expected structure: install_dir// + // Expected structure by default: install_dir// let browser_subdir = install_dir.join(browser_type.as_str()); // Try firefox first (preferred), then firefox-bin @@ -198,8 +198,8 @@ mod linux { } BrowserType::Camoufox => { vec![ - browser_subdir.join("camoufox-bin"), - browser_subdir.join("camoufox"), + install_dir.join("camoufox-bin"), + install_dir.join("camoufox"), ] } _ => vec![], @@ -213,9 +213,9 @@ mod linux { Err( format!( - "Firefox executable not found in {}/{}", + "Executable not found for {} in {}", + browser_type.as_str(), install_dir.display(), - browser_type.as_str() ) .into(), ) @@ -256,10 +256,6 @@ mod linux { // Expected structure: install_dir// let browser_subdir = install_dir.join(browser_type.as_str()); - if !browser_subdir.exists() || !browser_subdir.is_dir() { - return false; - } - let possible_executables = match browser_type { BrowserType::Firefox | BrowserType::FirefoxDeveloper => { vec![ @@ -286,8 +282,8 @@ mod linux { } BrowserType::Camoufox => { vec![ - browser_subdir.join("camoufox-bin"), - browser_subdir.join("camoufox"), + install_dir.join("camoufox-bin"), + install_dir.join("camoufox"), ] } _ => vec![], diff --git a/src-tauri/src/extraction.rs b/src-tauri/src/extraction.rs index 6386517..6ae2b66 100644 --- a/src-tauri/src/extraction.rs +++ b/src-tauri/src/extraction.rs @@ -45,6 +45,12 @@ impl Extractor { return Ok(()); }; + // For Camoufox on Linux, we expect the executable directly under version directory + // e.g., binaries/camoufox//camoufox, without an extra camoufox/ subdirectory + if browser_type == "camoufox" { + return Ok(()); + } + let expected_subdir = dest_dir.join(browser_type); // If the executable is not in the expected subdirectory, create the structure diff --git a/src-tauri/src/profile/manager.rs b/src-tauri/src/profile/manager.rs index 9b332f9..d9a1daf 100644 --- a/src-tauri/src/profile/manager.rs +++ b/src-tauri/src/profile/manager.rs @@ -603,6 +603,11 @@ impl ProfileManager { })?; } + // Emit profile update event so frontend UIs can refresh immediately (e.g. proxy manager) + if let Err(e) = app_handle.emit("profile-updated", &profile) { + println!("Warning: Failed to emit profile update event: {e}"); + } + Ok(profile) }