From 577bf47471fb7cd9c4bee42fd90528d36e5e9ae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mikrut?= Date: Sun, 15 Oct 2023 22:21:26 +0200 Subject: [PATCH] ASG --- czkawka_core/src/common_directory.rs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/czkawka_core/src/common_directory.rs b/czkawka_core/src/common_directory.rs index 5fa6a43..3e5a96b 100644 --- a/czkawka_core/src/common_directory.rs +++ b/czkawka_core/src/common_directory.rs @@ -134,19 +134,24 @@ impl Directories { } // Try to canonicalize them - if let Ok(dir) = directory.canonicalize() { - directory = dir; - dbg!("Is canonicalize", &directory); - } + if cfg!(windows) { - dbg!("Before windows", &directory); - let path_str = directory.to_string_lossy().to_string(); - if let Some(path_str) = path_str.strip_prefix(r"\\?\") { - if path_str.chars().nth(1) == Some(':') { - directory = PathBuf::from(path_str); + // Only canonicalize if it's not a network path + // This can be check by checking if path starts with \\?\UNC\ + if let Ok(dir_can) = directory.canonicalize() { + let dir_can_str = dir_can.to_string_lossy().to_string(); + if dir_can_str.starts_with(r"\\?\") && dir_can_str.chars().nth(5) == Some(':') { + directory = PathBuf::from(dir_can_str); } + + directory = dir_can; + dbg!("After canonicalize", &directory); + } + } else { + if let Ok(dir) = directory.canonicalize() { + directory = dir; + dbg!("Is canonicalize UNIX", &directory); } - dbg!("After windows", &directory); } (Some(directory), messages) }