From 57570c3ba67f23d42b2e8c6dcf8be4668a0f290d Mon Sep 17 00:00:00 2001 From: 21pages Date: Sat, 8 Jun 2024 21:56:47 +0800 Subject: [PATCH] is_ipc_file_exist quote Config::ipc_path (#8295) Signed-off-by: 21pages --- src/ipc.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ipc.rs b/src/ipc.rs index c660fc33f..a10a8f955 100644 --- a/src/ipc.rs +++ b/src/ipc.rs @@ -972,9 +972,11 @@ pub async fn test_rendezvous_server() -> ResultType<()> { #[cfg(windows)] pub fn is_ipc_file_exist(suffix: &str) -> ResultType { - let file_name = format!("{}\\query{}", crate::get_app_name(), suffix); + // Not change this to std::path::Path::exists, unless it can be ensured that it can find the ipc which occupied by a process that taskkill can't kill. + let prefix = "\\\\.\\pipe\\"; + let file_name = Config::ipc_path(suffix).replace(prefix, ""); let mut err = None; - for entry in std::fs::read_dir("\\\\.\\pipe\\")? { + for entry in std::fs::read_dir(prefix)? { match entry { Ok(entry) => { if entry.file_name().into_string().unwrap_or_default() == file_name {