From 99277b9ea50f2e08dab7343e5cf3b89afa23b769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mikrut?= <41945903+qarmin@users.noreply.github.com> Date: Mon, 16 Oct 2023 09:22:22 +0200 Subject: [PATCH] Try to fix issue with missing samba drives (#1096) * GA * GA * GA * GAS * KDV * ASG * Wa * BKF * Fmt --- .gitignore | 3 ++- czkawka_core/src/common_directory.rs | 20 ++++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 830c5ece5..298e00bba 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,5 @@ flatpak/ ci_tester/target ci_tester/Cargo.lock czkawka_slint_gui/Cargo.lock -czkawka_slint_gui/target \ No newline at end of file +czkawka_slint_gui/target +*.json \ No newline at end of file diff --git a/czkawka_core/src/common_directory.rs b/czkawka_core/src/common_directory.rs index f85390e5d..378c5f358 100644 --- a/czkawka_core/src/common_directory.rs +++ b/czkawka_core/src/common_directory.rs @@ -122,13 +122,21 @@ impl Directories { } // Try to canonicalize them - if let Ok(dir) = directory.canonicalize() { - directory = dir; - } + if cfg!(windows) { - let path_str = directory.to_string_lossy().to_string(); - if let Some(path_str) = path_str.strip_prefix(r"\\?\") { - 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 let Some(dir_can_str) = dir_can_str.strip_prefix(r"\\?\") { + if dir_can_str.chars().nth(1) == Some(':') { + directory = PathBuf::from(dir_can_str); + } + } + } + } else { + if let Ok(dir) = directory.canonicalize() { + directory = dir; } } (Some(directory), messages)