Do not crash if a FileRoot is a symlink

This commit is contained in:
Aria Desires 2025-10-23 18:20:39 -04:00
parent 05cde8bd19
commit b96e1b9759
1 changed files with 8 additions and 2 deletions

View File

@ -190,7 +190,10 @@ impl Files {
let roots = self.inner.roots.read().unwrap();
let absolute = SystemPath::absolute(path, db.system().current_directory());
roots.at(&absolute)
// We need to resolve away symlinks here to avoid getting confused about subdirectories.
let canonicalized = db.system().canonicalize_path(&absolute).unwrap_or(absolute);
roots.at(&canonicalized)
}
/// The same as [`Self::root`] but panics if no root is found.
@ -211,7 +214,10 @@ impl Files {
let mut roots = self.inner.roots.write().unwrap();
let absolute = SystemPath::absolute(path, db.system().current_directory());
roots.try_add(db, absolute, kind)
// We need to resolve away symlinks here to avoid getting confused about subdirectories.
let canonicalized = db.system().canonicalize_path(&absolute).unwrap_or(absolute);
roots.try_add(db, canonicalized, kind)
}
/// Updates the revision of the root for `path`.