From 6849e106ba32bf1d484930208ff9dfc372b17144 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Mon, 19 May 2025 04:34:46 +0200 Subject: [PATCH] Cleanup --- apps/desktop/desktop_native/core/src/ipc/mod.rs | 10 ++++++++-- apps/desktop/desktop_native/core/src/ipc/server.rs | 6 ++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/desktop/desktop_native/core/src/ipc/mod.rs b/apps/desktop/desktop_native/core/src/ipc/mod.rs index 8fd1724d49c..72bc373d3a9 100644 --- a/apps/desktop/desktop_native/core/src/ipc/mod.rs +++ b/apps/desktop/desktop_native/core/src/ipc/mod.rs @@ -1,3 +1,5 @@ +use std::vec; + use tokio::io::{AsyncRead, AsyncWrite}; use tokio_util::codec::{Framed, LengthDelimitedCodec}; @@ -93,7 +95,6 @@ pub fn path(name: &str) -> std::path::PathBuf { /// Paths to the ipc sockets including alternative paths. /// For flatpak, a path per sandbox is created. pub fn all_paths(name: &str) -> Vec { - let paths = vec![path(name)]; #[cfg(target_os = "linux")] { // On Linux, in flatpak, we mount sockets in each app's sandboxed directory. @@ -103,7 +104,12 @@ pub fn all_paths(name: &str) -> Vec { .iter() .map(|path| flatpak_path.join(path).join(format!(".app.{name}.socket"))) .collect::>(); + let mut paths = vec![path(name)]; paths.extend(flatpak_paths); + paths + } + #[cfg(not(target_os = "linux"))] + { + vec![path(name)] } - paths } diff --git a/apps/desktop/desktop_native/core/src/ipc/server.rs b/apps/desktop/desktop_native/core/src/ipc/server.rs index ffd0fb74e92..e1ed3bcb90f 100644 --- a/apps/desktop/desktop_native/core/src/ipc/server.rs +++ b/apps/desktop/desktop_native/core/src/ipc/server.rs @@ -57,10 +57,8 @@ impl Server { for path in paths.iter() { // If the unix socket file already exists, we get an error when trying to bind to it. So we remove it first. // Any processes that were using the old socket should remain connected to it but any new connections will use the new socket. - if !cfg!(windows) { - if path.exists() { - std::fs::remove_file(path)?; - } + if !cfg!(windows) && path.exists() { + std::fs::remove_file(path)?; } let name = path.as_os_str().to_fs_name::()?;