Fix the Clippy findings in the Linux-only code paths

This commit is contained in:
Thorsten Sommer committed 2026-09-13 13:20:34 +02:00
1 parent 08b6a190a8
commit 9c3fcbf815
3 files changed
+43 -39

No files matched your search

+4 -4
View File
@@ -504,10 +504,10 @@ fn read_locale_from_environment() -> Option<(String, &'static str)> {
} }
for key in ["LC_ALL", "LC_MESSAGES", "LANG"] { for key in ["LC_ALL", "LC_MESSAGES", "LANG"] {
if let Ok(value) = env::var(key) { if let Ok(value) = env::var(key)
if let Some(locale) = normalize_locale_tag(&value) { && let Some(locale) = normalize_locale_tag(&value)
return Some((locale, key)); {
} return Some((locale, key));
} }
} }
+35 -31
View File
@@ -149,6 +149,12 @@ struct ShortcutManager {
/// Stores the backend-specific resources required by an active shortcut. /// Stores the backend-specific resources required by an active shortcut.
enum ActiveBinding { enum ActiveBinding {
/// Stores a shortcut registered through the Tauri plugin. /// Stores a shortcut registered through the Tauri plugin.
///
/// Never constructed on Linux: registration there goes through the XDG portal and falls back
/// to the focused window, so nothing ever reaches the Tauri plugin. The variant stays all the
/// same, because the code which releases, suspends, and restores bindings is shared across
/// platforms and would otherwise have to be cut in two for one unreachable case.
#[cfg_attr(target_os = "linux", allow(dead_code))]
Tauri { Tauri {
/// Contains the registered shortcut in Tauri syntax. /// Contains the registered shortcut in Tauri syntax.
shortcut: String, shortcut: String,
@@ -247,40 +253,38 @@ pub async fn register(
} }
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
{ match prepare_portal_binding(&request, event_sender.clone()).await {
match prepare_portal_binding(&request, event_sender.clone()).await { Ok(new_binding) => {
Ok(new_binding) => { let effective_display_name = new_binding.effective_display_name();
let effective_display_name = new_binding.effective_display_name(); replace_portal_binding(&app_handle, &mut manager, request.id, new_binding).await;
replace_portal_binding(&app_handle, &mut manager, request.id, new_binding).await; info!(Source = "XDG portal"; "Global shortcut '{}' is active through the desktop portal.", request.id);
info!(Source = "XDG portal"; "Global shortcut '{}' is active through the desktop portal.", request.id); ShortcutResponse::success(ShortcutBackend::Portal, effective_display_name)
return ShortcutResponse::success(ShortcutBackend::Portal, effective_display_name); },
},
Err(error) => { Err(error) => {
let current_backend = manager.bindings.get(&request.id).map(ActiveBinding::backend); let current_backend = manager.bindings.get(&request.id).map(ActiveBinding::backend);
if may_fallback_to_local(error.kind, current_backend) { if may_fallback_to_local(error.kind, current_backend) {
warn!(Source = "XDG portal"; "Global shortcut registration failed; using the focused-window fallback: {}", error.message); warn!(Source = "XDG portal"; "Global shortcut registration failed; using the focused-window fallback: {}", error.message);
if let Some(old_binding) = manager.bindings.remove(&request.id) { if let Some(old_binding) = manager.bindings.remove(&request.id) {
close_binding(&app_handle, request.id, old_binding).await; close_binding(&app_handle, request.id, old_binding).await;
}
manager.bindings.insert(request.id, ActiveBinding::Local { shortcut: request.shortcut.clone() });
return ShortcutResponse::success(ShortcutBackend::Local, request.shortcut);
} else {
let cancelled = error.kind == PortalFailureKind::Cancelled;
if cancelled {
warn!(Source = "XDG portal"; "Global shortcut configuration was cancelled by the user; preserving the active portal binding.");
} else if error.kind == PortalFailureKind::Denied {
warn!(Source = "XDG portal"; "Global shortcut permission was denied; preserving the active portal binding: {}", error.message);
} else {
error!(Source = "XDG portal"; "Global shortcut registration failed; preserving the active portal binding: {}", error.message);
}
return ShortcutResponse::error(error.message, ShortcutBackend::Portal, cancelled);
} }
},
} manager.bindings.insert(request.id, ActiveBinding::Local { shortcut: request.shortcut.clone() });
ShortcutResponse::success(ShortcutBackend::Local, request.shortcut)
} else {
let cancelled = error.kind == PortalFailureKind::Cancelled;
if cancelled {
warn!(Source = "XDG portal"; "Global shortcut configuration was cancelled by the user; preserving the active portal binding.");
} else if error.kind == PortalFailureKind::Denied {
warn!(Source = "XDG portal"; "Global shortcut permission was denied; preserving the active portal binding: {}", error.message);
} else {
error!(Source = "XDG portal"; "Global shortcut registration failed; preserving the active portal binding: {}", error.message);
}
ShortcutResponse::error(error.message, ShortcutBackend::Portal, cancelled)
}
},
} }
#[cfg(not(target_os = "linux"))] #[cfg(not(target_os = "linux"))]
+4 -4
View File
@@ -23,10 +23,10 @@ fn issue_code(error: &KeyringError) -> SecretStoreIssueCode {
} }
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
if let KeyringError::PlatformFailure(error) | KeyringError::NoStorageAccess(error) = error { if let KeyringError::PlatformFailure(error) | KeyringError::NoStorageAccess(error) = error
if let Some(error) = error.downcast_ref::<dbus_secret_service::Error>() { && let Some(error) = error.downcast_ref::<dbus_secret_service::Error>()
return secret_service_issue_code(error); {
} return secret_service_issue_code(error);
} }
SecretStoreIssueCode::Unknown SecretStoreIssueCode::Unknown