Canonicalize Windows paths

This commit is contained in:
Gedeon Sainrival
2026-01-28 21:42:57 -05:00
parent 14901455b2
commit d31fc97c8c

View File

@@ -944,7 +944,24 @@ impl VolumeManager {
pub async fn volume_for_path(&self, path: &Path) -> Option<Volume> {
// 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