From a3db6475ca636db466a60cd66316f17912547f08 Mon Sep 17 00:00:00 2001 From: Misieq01 <38589417+Misieq01@users.noreply.github.com> Date: Fri, 28 Feb 2025 13:24:08 +0100 Subject: [PATCH] fix: autolauncher-edge-case (#1587) Fixes #1586 ## Summary by CodeRabbit - **Refactor** - Enhanced error handling and logging for the auto-launch feature, ensuring that issues during startup are recorded without interrupting operations. - Adjusted the initialization process to manage unused results, reducing unnecessary warnings and promoting a smoother, more robust experience. --- src-tauri/src/auto_launcher.rs | 8 ++++++-- src-tauri/src/main.rs | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src-tauri/src/auto_launcher.rs b/src-tauri/src/auto_launcher.rs index 221dccdb5..5684898a6 100644 --- a/src-tauri/src/auto_launcher.rs +++ b/src-tauri/src/auto_launcher.rs @@ -115,7 +115,9 @@ impl AutoLauncher { auto_launcher.enable()?; // To startup application as admin on windows, we need to create a task scheduler #[cfg(target_os = "windows")] - self.toggle_windows_admin_auto_launcher(true).await?; + let _unused = self.toggle_windows_admin_auto_launcher(true).await.inspect_err(|e| { + warn!(target: LOG_TARGET, "Failed to enable admin auto-launcher: {}", e) + }); } _ => { auto_launcher.enable()?; @@ -126,7 +128,9 @@ impl AutoLauncher { match PlatformUtils::detect_current_os() { CurrentOperatingSystem::Windows => { #[cfg(target_os = "windows")] - self.toggle_windows_admin_auto_launcher(false).await?; + let _unused = self.toggle_windows_admin_auto_launcher(false).await.inspect_err(|e| { + warn!(target: LOG_TARGET, "Failed to disable admin auto-launcher: {}", e) + }); auto_launcher.disable()?; } _ => { diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 0c9b561e6..5ba294c1b 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -380,9 +380,10 @@ async fn setup_inner( let mm_proxy_manager = state.mm_proxy_manager.clone(); let is_auto_launcher_enabled = state.config.read().await.should_auto_launch(); - AutoLauncher::current() + let _unused = AutoLauncher::current() .initialize_auto_launcher(is_auto_launcher_enabled) - .await?; + .await + .inspect_err(|e| error!(target: LOG_TARGET, "Could not initialize auto launcher: {:?}", e)); let (tx, rx) = watch::channel("".to_string()); let progress = ProgressTracker::new(app.clone(), Some(tx));