Skip to content

Commit

Permalink
fix: autolauncher-edge-case (#1587)
Browse files Browse the repository at this point in the history
Fixes #1586 

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## 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.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
Misieq01 authored Feb 28, 2025
1 parent 6e57869 commit a3db647
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src-tauri/src/auto_launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand All @@ -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()?;
}
_ => {
Expand Down
5 changes: 3 additions & 2 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit a3db647

Please sign in to comment.