Repository: qarmin/czkawka (language: rust)

Issue:
Windows 10 mapped SMB network drives not included in scans in 6.1.0
**Desktop:**

- Czkawka version
6.1.0 Windows GUI
- OS version:
Windows 10

Since upgrading from 6.0.0 to 6.1.0 this morning, folders on mapped SMB network drives in Windows are being dropped by the new optimization code.  If they are the only folders selected to search, this leads to a misleading error

`Directories: All directories to search overlaps with excluded directories`

[This error is printed when all folders have been optimized out, whether or not they overlap with excluded directories](https://github.com/qarmin/czkawka/blob/59ff9f3e3c8ebda294b2a80a8dd9b79c9cd07f28/czkawka_core/src/common_directory.rs#L272).  I don't know which step of the optimization code is dropping the folders, but I'm only seeing this behavior for folders located on SMB network shares that I've mapped to drives in Windows 10.

...



Discussion / hints:
Can confirm this. Only have a share and not excluded paths.
Windows 11 here.

Fix patch:
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)


Test patch: