Skip to content

Commit 78f2565

Browse files
authored
fix: allow return value of fs::canonicalize on fs scope, closes #4130 (#4188)
1 parent 72700ec commit 78f2565

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

.changes/fix-fs-scope-windows.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri": patch
3+
---
4+
5+
Allow the canonical, absolute form of a path for the filesystem scope on Windows if `std::fs::canonicalize` returns a path, fallback to `\\?\$PATH`.

core/tauri/src/scope/fs.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ fn push_pattern<P: AsRef<Path>>(list: &mut HashSet<Pattern>, pattern: P) -> crat
6969
list.insert(Pattern::new(&path.to_string_lossy())?);
7070
#[cfg(windows)]
7171
{
72-
list.insert(Pattern::new(&format!("\\\\?\\{}", path.display()))?);
72+
if let Ok(p) = std::fs::canonicalize(&path) {
73+
list.insert(Pattern::new(&p.to_string_lossy())?);
74+
} else {
75+
list.insert(Pattern::new(&format!("\\\\?\\{}", path.display()))?);
76+
}
7377
}
7478
Ok(())
7579
}

0 commit comments

Comments
 (0)