diff --git a/src-tauri/src/browser_runner.rs b/src-tauri/src/browser_runner.rs index f653657..58e281a 100644 --- a/src-tauri/src/browser_runner.rs +++ b/src-tauri/src/browser_runner.rs @@ -1642,7 +1642,8 @@ impl BrowserRunner { let binaries_dir = self.get_binaries_dir(); // Use comprehensive cleanup that syncs registry with disk and removes unused binaries - let cleaned_up = registry.comprehensive_cleanup(&binaries_dir, &active_versions, &running_versions)?; + let cleaned_up = + registry.comprehensive_cleanup(&binaries_dir, &active_versions, &running_versions)?; // Registry is already saved by comprehensive_cleanup Ok(cleaned_up) diff --git a/src-tauri/src/downloaded_browsers.rs b/src-tauri/src/downloaded_browsers.rs index 056e484..f1be4c8 100644 --- a/src-tauri/src/downloaded_browsers.rs +++ b/src-tauri/src/downloaded_browsers.rs @@ -267,7 +267,7 @@ impl DownloadedBrowsersRegistry { binaries_dir: &std::path::Path, ) -> Result, Box> { let mut changes = Vec::new(); - + if !binaries_dir.exists() { return Ok(changes); } @@ -276,15 +276,16 @@ impl DownloadedBrowsersRegistry { for browser_entry in fs::read_dir(binaries_dir)? { let browser_entry = browser_entry?; let browser_path = browser_entry.path(); - + if !browser_path.is_dir() { continue; } - - let browser_name = browser_path.file_name() + + let browser_name = browser_path + .file_name() .and_then(|n| n.to_str()) .unwrap_or(""); - + if browser_name.is_empty() || browser_name.starts_with('.') { continue; } @@ -293,15 +294,16 @@ impl DownloadedBrowsersRegistry { for version_entry in fs::read_dir(&browser_path)? { let version_entry = version_entry?; let version_path = version_entry.path(); - + if !version_path.is_dir() { continue; } - - let version_name = version_path.file_name() + + let version_name = version_path + .file_name() .and_then(|n| n.to_str()) .unwrap_or(""); - + if version_name.is_empty() || version_name.starts_with('.') { continue; } @@ -319,11 +321,11 @@ impl DownloadedBrowsersRegistry { } } } - + if !changes.is_empty() { self.save()?; } - + Ok(changes) } @@ -335,23 +337,23 @@ impl DownloadedBrowsersRegistry { running_profiles: &[(String, String)], ) -> Result, Box> { let mut cleanup_results = Vec::new(); - + // First, sync registry with actual binaries on disk let sync_results = self.sync_with_binaries_directory(binaries_dir)?; cleanup_results.extend(sync_results); - + // Then perform the regular cleanup let regular_cleanup = self.cleanup_unused_binaries(active_profiles, running_profiles)?; cleanup_results.extend(regular_cleanup); - + // Finally, verify and cleanup stale entries let stale_cleanup = self.verify_and_cleanup_stale_entries_simple(binaries_dir)?; cleanup_results.extend(stale_cleanup); - + if !cleanup_results.is_empty() { self.save()?; } - + Ok(cleanup_results) } @@ -364,7 +366,7 @@ impl DownloadedBrowsersRegistry { let mut browsers_to_remove = Vec::new(); for (browser_str, versions) in &self.browsers { - for (version, _info) in versions { + for version in versions.keys() { // Check if the browser directory actually exists let browser_dir = binaries_dir.join(browser_str).join(version); if !browser_dir.exists() { @@ -376,7 +378,9 @@ impl DownloadedBrowsersRegistry { // Remove stale entries for (browser_str, version) in browsers_to_remove { if let Some(_removed) = self.remove_browser(&browser_str, &version) { - cleaned_up.push(format!("Removed stale registry entry for {browser_str} {version}")); + cleaned_up.push(format!( + "Removed stale registry entry for {browser_str} {version}" + )); } } diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 5c465a5..8ca48fc 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -31,13 +31,12 @@ mod version_updater; extern crate lazy_static; use browser_runner::{ - check_browser_exists, check_browser_status, check_missing_binaries, - create_browser_profile_new, delete_profile, download_browser, ensure_all_binaries_exist, - fetch_browser_versions_cached_first, fetch_browser_versions_with_count, - fetch_browser_versions_with_count_cached_first, get_browser_release_types, - get_downloaded_browser_versions, get_supported_browsers, is_browser_supported_on_platform, - kill_browser_profile, launch_browser_profile, list_browser_profiles, rename_profile, - update_profile_proxy, update_profile_version, + check_browser_exists, check_browser_status, check_missing_binaries, create_browser_profile_new, + delete_profile, download_browser, ensure_all_binaries_exist, fetch_browser_versions_cached_first, + fetch_browser_versions_with_count, fetch_browser_versions_with_count_cached_first, + get_browser_release_types, get_downloaded_browser_versions, get_supported_browsers, + is_browser_supported_on_platform, kill_browser_profile, launch_browser_profile, + list_browser_profiles, rename_profile, update_profile_proxy, update_profile_version, }; use settings_manager::{ @@ -409,7 +408,7 @@ pub fn run() { tauri::async_runtime::spawn(async move { println!("Starting nodecar warm-up..."); let start_time = std::time::Instant::now(); - + // Send a ping request to nodecar to trigger unpacking/warm-up match tokio::process::Command::new("nodecar") .arg("--version") @@ -419,14 +418,23 @@ pub fn run() { Ok(output) => { let duration = start_time.elapsed(); if output.status.success() { - println!("Nodecar warm-up completed successfully in {:.2}s", duration.as_secs_f64()); + println!( + "Nodecar warm-up completed successfully in {:.2}s", + duration.as_secs_f64() + ); } else { - println!("Nodecar warm-up completed with non-zero exit code in {:.2}s", duration.as_secs_f64()); + println!( + "Nodecar warm-up completed with non-zero exit code in {:.2}s", + duration.as_secs_f64() + ); } } Err(e) => { let duration = start_time.elapsed(); - println!("Nodecar warm-up failed after {:.2}s: {e}", duration.as_secs_f64()); + println!( + "Nodecar warm-up failed after {:.2}s: {e}", + duration.as_secs_f64() + ); } } }); diff --git a/src-tauri/src/proxy_manager.rs b/src-tauri/src/proxy_manager.rs index 7a8ae86..438490b 100644 --- a/src-tauri/src/proxy_manager.rs +++ b/src-tauri/src/proxy_manager.rs @@ -780,9 +780,7 @@ mod tests { .arg("--type") .arg("http"); - let start_time = std::time::Instant::now(); let output = tokio::time::timeout(Duration::from_secs(60), async { cmd.output() }).await??; - let execution_time = start_time.elapsed(); if output.status.success() { let stdout = String::from_utf8(output.stdout)?;