From 703154b30f23f243e68c458ffe63b408be2095de Mon Sep 17 00:00:00 2001 From: zhom <2717306+zhom@users.noreply.github.com> Date: Tue, 17 Jun 2025 07:00:18 +0400 Subject: [PATCH] chore: linting --- src-tauri/src/auto_updater.rs | 77 +++++++++++++++----------------- src-tauri/src/lib.rs | 2 +- src-tauri/src/version_updater.rs | 5 ++- 3 files changed, 41 insertions(+), 43 deletions(-) diff --git a/src-tauri/src/auto_updater.rs b/src-tauri/src/auto_updater.rs index ee06d0b..d2bb408 100644 --- a/src-tauri/src/auto_updater.rs +++ b/src-tauri/src/auto_updater.rs @@ -121,51 +121,48 @@ impl AutoUpdater { Ok(notifications) } - - pub async fn check_for_updates_with_progress( - &self, - app_handle: &tauri::AppHandle, - ) { - // Check for browser updates and trigger auto-downloads - match self.check_for_updates().await { - Ok(update_notifications) => { - if !update_notifications.is_empty() { + + pub async fn check_for_updates_with_progress(&self, app_handle: &tauri::AppHandle) { + // Check for browser updates and trigger auto-downloads + match self.check_for_updates().await { + Ok(update_notifications) => { + if !update_notifications.is_empty() { + println!( + "Found {} browser updates to auto-download", + update_notifications.len() + ); + + // Trigger automatic downloads for each update + for notification in update_notifications { println!( - "Found {} browser updates to auto-download", - update_notifications.len() + "Auto-downloading {} version {}", + notification.browser, notification.new_version ); - // Trigger automatic downloads for each update - for notification in update_notifications { - println!( - "Auto-downloading {} version {}", - notification.browser, notification.new_version + // Emit a custom event to trigger auto-download + let auto_update_event = serde_json::json!({ + "browser": notification.browser, + "new_version": notification.new_version, + "notification_id": notification.id, + "affected_profiles": notification.affected_profiles + }); + + if let Err(e) = app_handle.emit("browser-auto-update-available", &auto_update_event) { + eprintln!( + "Failed to emit auto-update event for {}: {e}", + notification.browser ); - - // Emit a custom event to trigger auto-download - let auto_update_event = serde_json::json!({ - "browser": notification.browser, - "new_version": notification.new_version, - "notification_id": notification.id, - "affected_profiles": notification.affected_profiles - }); - - if let Err(e) = app_handle.emit("browser-auto-update-available", &auto_update_event) { - eprintln!( - "Failed to emit auto-update event for {}: {e}", - notification.browser - ); - } else { - println!("Emitted auto-update event for {}", notification.browser); - } + } else { + println!("Emitted auto-update event for {}", notification.browser); } - } else { - println!("No browser updates needed"); } + } else { + println!("No browser updates needed"); } - Err(e) => { - eprintln!("Failed to check for browser updates: {e}"); - } + } + Err(e) => { + eprintln!("Failed to check for browser updates: {e}"); + } } } @@ -475,9 +472,7 @@ pub async fn complete_browser_update_with_auto_update( } #[tauri::command] -pub async fn check_for_updates_with_progress( - app_handle: tauri::AppHandle, -) { +pub async fn check_for_updates_with_progress(app_handle: tauri::AppHandle) { let updater = AutoUpdater::new(); updater.check_for_updates_with_progress(&app_handle).await; } diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index c6dd4ad..d1e82db 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -298,7 +298,7 @@ pub fn run() { }); let app_handle_auto_updater = app.handle().clone(); - + // Start the auto-update check task separately tauri::async_runtime::spawn(async move { auto_updater::check_for_updates_with_progress(app_handle_auto_updater).await; diff --git a/src-tauri/src/version_updater.rs b/src-tauri/src/version_updater.rs index d2a04b6..5f2e7f3 100644 --- a/src-tauri/src/version_updater.rs +++ b/src-tauri/src/version_updater.rs @@ -385,7 +385,10 @@ impl VersionUpdater { tokio::time::sleep(Duration::from_millis(200)).await; } - self.auto_updater.check_for_updates_with_progress(app_handle).await; + self + .auto_updater + .check_for_updates_with_progress(app_handle) + .await; // Emit completion event let progress = VersionUpdateProgress {