mirror of
https://github.com/sigoden/dufs.git
synced 2026-04-08 16:49:02 +03:00
[GH-ISSUE #654] Some search results missing if broken symlinks are present #397
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jamesscottbrown on GitHub (Jan 5, 2026).
Original GitHub issue: https://github.com/sigoden/dufs/issues/654
Problem
The
collect_dir_entriesfunction doesn't handle errors when listing files in the serve path.I was using dufs to serve a directory that contained some broken symbolic links, and this was causing other files to be missing from the list of search results. This problem occurs whether or not the user specifies
--allow-symlink, as the WalkDir iterator hasfollow_linksenabled (let mut it = WalkDir::new(&dir).follow_links(true).into_iter()).It took me a while to realise what the problem was, as no errors are logged or returned as a response to the search query.
@sigoden commented on GitHub (Jan 9, 2026):
I can't confirm the issue you're referring to.
The
follow_linksinWalkDir::new(&dir).follow_links(true)is not problematic; symlink issues are handled separately within the loop.2b2c7bd5f7/src/server.rs (L1898-L1904)@jamesscottbrown commented on GitHub (Jan 20, 2026):
Yes, this is fine - it just means that telling dufs not to follow the symlinks does not work as a work-around for the underlying problem.
The actual problem is the
while let Some(Ok(entry)) = it.next(), which means the loop terminates early ifit.next()encounters an error.Here's a more explicit demonstration with a minimal program to show the problem:
src/main.rs:Cargo.toml:
Demonstration:
With no broken symlinks, there are no errors encountered and all files are iterated over:
However, if I create a broken symlink then some are missed:
The same thing would happen if WalkDir encountered a different type of error.