Skip to content

Commit

Permalink
Fix hang on symlinks to inaccessible filesystems
Browse files Browse the repository at this point in the history
Never consider a symlink to be a subdirectory; this prevents hanging
when the symlink points to a slow/inaccessible filesystem.
  • Loading branch information
lutzky committed Jul 18, 2023
1 parent d6a2c55 commit 6f00730
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,14 @@ impl DirContents {
.filter_map(|(_, entry)| entry.ok())
.for_each(|entry| {
let path = PathBuf::from(entry.path().strip_prefix(base).unwrap());
if entry.path().is_dir() {

// Avoid using path.is_dir, as that follows the symlink,
// potentially into a slow/inaccessible filesystem.
let is_dir = fs::symlink_metadata(&path)
.map(|m| m.is_dir())
.unwrap_or(false);

if is_dir {
folders.insert(path);
} else {
if !path.to_string_lossy().starts_with('.') {
Expand Down

0 comments on commit 6f00730

Please sign in to comment.