diff --git a/runtime/src/app_window.rs b/runtime/src/app_window.rs index f9ec3dbb..b52be5a5 100644 --- a/runtime/src/app_window.rs +++ b/runtime/src/app_window.rs @@ -245,10 +245,8 @@ fn should_open_in_system_browser(webview: &tauri::Webview, } } - if let Ok(current_url) = webview.url() { - if same_origin(¤t_url, url) { - return false; - } + if let Ok(current_url) = webview.url() && same_origin(¤t_url, url) { + return false; } !is_local_host(url.host_str()) @@ -415,10 +413,8 @@ pub async fn change_location_to(url: &str) { } } - if let Ok(parsed_url) = tauri::Url::parse(url) { - if is_local_http_url(&parsed_url) { - *APPROVED_APP_URL.lock().unwrap() = Some(parsed_url); - } + if let Ok(parsed_url) = tauri::Url::parse(url) && is_local_http_url(&parsed_url) { + *APPROVED_APP_URL.lock().unwrap() = Some(parsed_url); } let js_location_change = format!("window.location = '{url}';"); @@ -685,12 +681,10 @@ pub async fn register_shortcut(_token: APIToken, payload: Json info!(Source = "Tauri"; "Unregistered old shortcut '{old_shortcut}' for '{}'.", id), - Err(error) => warn!(Source = "Tauri"; "Failed to unregister old shortcut '{old_shortcut}': {error}"), - } + if let Some(old_shortcut) = registered_shortcuts.get(&id) && !old_shortcut.is_empty() { + match shortcut_manager.unregister(old_shortcut.as_str()) { + Ok(_) => info!(Source = "Tauri"; "Unregistered old shortcut '{old_shortcut}' for '{}'.", id), + Err(error) => warn!(Source = "Tauri"; "Failed to unregister old shortcut '{old_shortcut}': {error}"), } } diff --git a/runtime/src/environment.rs b/runtime/src/environment.rs index 68198fbd..1e45b5f3 100644 --- a/runtime/src/environment.rs +++ b/runtime/src/environment.rs @@ -87,10 +87,8 @@ fn normalize_locale_tag(locale: &str) -> Option { return None; } - if let Some(region) = segments.next() { - if region.len() == 2 && region.chars().all(|c| c.is_ascii_alphabetic()) { - return Some(format!("{}-{}", language, region.to_ascii_uppercase())); - } + if let Some(region) = segments.next() && region.len() == 2 && region.chars().all(|c| c.is_ascii_alphabetic()) { + return Some(format!("{}-{}", language, region.to_ascii_uppercase())); } Some(language) @@ -418,10 +416,9 @@ fn load_policy_values_from_directories(directories: &[PathBuf]) -> HashMap Json { /// Starts the Qdrant server in a separate process. pub fn start_qdrant_server(app_handle: tauri::AppHandle){ let path = qdrant_base_path(); - if !path.exists() { - if let Err(e) = fs::create_dir_all(&path){ - error!(Source="Qdrant"; "The required directory to host the Qdrant database could not be created: {}", e); - set_qdrant_unavailable(format!("The Qdrant data directory could not be created: {e}")); - return; - }; + if !path.exists() && let Err(e) = fs::create_dir_all(&path){ + error!(Source="Qdrant"; "The required directory to host the Qdrant database could not be created: {}", e); + set_qdrant_unavailable(format!("The Qdrant data directory could not be created: {e}")); + return; } let (cert_path, key_path) = match create_temp_tls_files(&path) { diff --git a/runtime/src/stale_process_cleanup.rs b/runtime/src/stale_process_cleanup.rs index 7d177ac8..73e92111 100644 --- a/runtime/src/stale_process_cleanup.rs +++ b/runtime/src/stale_process_cleanup.rs @@ -50,7 +50,7 @@ pub fn kill_stale_process(pid_file_path: PathBuf, sidecar_type: SidecarType) -> let killed = process.kill_with(Signal::Kill).unwrap_or_else(|| process.kill()); if !killed { - return Err(Error::new(ErrorKind::Other, "Failed to kill process")); + return Err(Error::other("Failed to kill process")); } info!(Source="Stale Process Cleanup";"{}: Killed process: \"{}\"", sidecar_type,pid_file_path.display()); } else {