mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-22 21:41:37 +00:00
Improve project file prefetching by canonicalizing paths
- Updated the `prefetch_project_files` function to canonicalize folder paths before checking if roots start with the folder, preventing false positives with relative paths. - Enhanced the logic to skip non-existent roots early, improving efficiency during the prefetching process. These changes enhance the accuracy and performance of the file prefetching mechanism in the VFS.
This commit is contained in:
parent
aa203177a9
commit
df773eab71
1 changed files with 9 additions and 1 deletions
|
|
@ -178,8 +178,16 @@ fn prefetch_project_files(project: &Project, sync_scripts_only: bool) -> io::Res
|
||||||
|
|
||||||
// Also walk $path roots that may be OUTSIDE the project folder
|
// Also walk $path roots that may be OUTSIDE the project folder
|
||||||
// (e.g. $path: "../module"). These wouldn't be covered above.
|
// (e.g. $path: "../module"). These wouldn't be covered above.
|
||||||
|
// Canonicalize before starts_with to resolve ".." components that
|
||||||
|
// would otherwise cause false positives (e.g. project/../module
|
||||||
|
// literally starts_with project/ but is actually a sibling).
|
||||||
|
let canonical_folder = std::fs::canonicalize(folder).unwrap_or_else(|_| folder.to_path_buf());
|
||||||
for root in &roots {
|
for root in &roots {
|
||||||
if !root.exists() || root.starts_with(folder) {
|
if !root.exists() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let canonical_root = std::fs::canonicalize(root).unwrap_or_else(|_| root.to_path_buf());
|
||||||
|
if canonical_root.starts_with(&canonical_folder) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for e in WalkDir::new(root).follow_links(true).into_iter().flatten() {
|
for e in WalkDir::new(root).follow_links(true).into_iter().flatten() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue