From d31fc97c8ca2520059a4d2feb447aac71dced2f5 Mon Sep 17 00:00:00 2001 From: Gedeon Sainrival Date: Wed, 28 Jan 2026 21:42:57 -0500 Subject: [PATCH] Canonicalize Windows paths --- core/src/volume/manager.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/core/src/volume/manager.rs b/core/src/volume/manager.rs index 6bcd9196c..474cd6f5a 100644 --- a/core/src/volume/manager.rs +++ b/core/src/volume/manager.rs @@ -944,7 +944,24 @@ impl VolumeManager { pub async fn volume_for_path(&self, path: &Path) -> Option { // Canonicalize the path to handle relative paths properly let canonical_path = match path.canonicalize() { - Ok(p) => p, + Ok(p) => { + // On Windows, canonicalize() returns UNC extended paths (\\?\D:\) + // which breaks starts_with() matching against normal mount points (D:\). + // Strip the \\?\ prefix to get a normal path. + #[cfg(windows)] + { + let s = p.to_string_lossy(); + if let Some(stripped) = s.strip_prefix(r"\\?\") { + PathBuf::from(stripped) + } else { + p + } + } + #[cfg(not(windows))] + { + p + } + } Err(e) => { debug!("Failed to canonicalize path {}: {}", path.display(), e); // If canonicalization fails, try with the original path