From 106d0a828fb7bbb068379b96eaa3c3b304b01c2a Mon Sep 17 00:00:00 2001 From: Misieq01 Date: Wed, 11 Dec 2024 09:44:07 +0100 Subject: [PATCH] limit planif build to windows --- src-tauri/Cargo.toml | 4 ++-- src-tauri/src/auto_launcher.rs | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index d3f110ec4..dce3dd98e 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -87,10 +87,10 @@ xz2 = { version = "0.1.7", features = ["static"] } # static bind lzma zip = "2.2.0" dirs = "5.0.1" tauri-plugin-process = "2" -planif = "1.0.0" -whoami = "1.5.2" [target.'cfg(windows)'.dependencies] +planif = "1.0.0" +whoami = "1.5.2" winreg = "0.52.0" # needed for keymanager. TODO: Find a way of creating a keymanager without bundling sqlite diff --git a/src-tauri/src/auto_launcher.rs b/src-tauri/src/auto_launcher.rs index 3dce94ba3..c8a2aec1c 100644 --- a/src-tauri/src/auto_launcher.rs +++ b/src-tauri/src/auto_launcher.rs @@ -26,15 +26,17 @@ use anyhow::anyhow; use auto_launch::{AutoLaunch, AutoLaunchBuilder}; use dunce::canonicalize; use log::{info, warn}; +#[cfg(target_os = "windows")] use planif::{ enums::TaskCreationFlags, schedule::TaskScheduler, schedule_builder::{Action, ScheduleBuilder}, settings::{LogonType, PrincipalSettings, RunLevel, Settings}, }; +#[cfg(target_os = "windows")] +use whoami::username; use tauri::utils::platform::current_exe; use tokio::sync::RwLock; -use whoami::username; use crate::utils::platform_utils::{CurrentOperatingSystem, PlatformUtils}; @@ -103,6 +105,7 @@ impl AutoLauncher { CurrentOperatingSystem::Windows => { 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(is_auto_launcher_enabled) .await?; } @@ -117,6 +120,7 @@ impl AutoLauncher { info!(target: LOG_TARGET, "Disabling auto-launcher"); match PlatformUtils::detect_current_os() { CurrentOperatingSystem::Windows => { + #[cfg(target_os = "windows")] self.toggle_windows_admin_auto_launcher(is_auto_launcher_enabled) .await?; auto_launcher.disable()?; @@ -130,6 +134,7 @@ impl AutoLauncher { Ok(()) } + #[cfg(target_os = "windows")] async fn toggle_windows_admin_auto_launcher( &self, config_is_auto_launcher_enabled: bool, @@ -151,6 +156,7 @@ impl AutoLauncher { Ok(()) } + #[cfg(target_os = "windows")] pub async fn create_task_scheduler_for_admin_startup( &self, is_triggered: bool,