mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-02-20 07:37:26 -05:00
Canonicalize Windows paths
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user