[GH-ISSUE #683] Search stops early when WalkDir encounters broken symlinks #1770

Open
opened 2026-04-10 17:14:35 +03:00 by zhus · 0 comments
Owner

Originally created by @dominikroblek on GitHub (Apr 9, 2026).
Original GitHub issue: https://github.com/sigoden/dufs/issues/683

Description

When --allow-search is enabled and the directory tree contains broken symlinks, search (?q=...) silently stops returning results for sibling directories that come after the directory containing the broken symlinks in filesystem order.

Root cause

In server.rs, collect_dir_entries uses:

while let Some(Ok(entry)) = it.next() {

WalkDir::new(&dir).follow_links(true) produces Some(Err(...)) when it encounters a broken symlink. The while let Some(Ok(entry)) pattern doesn't match Some(Err(...)), so the entire loop exits — skipping all remaining entries in the walk.

Steps to reproduce

mkdir -p /tmp/dufs-test/aaa/sub /tmp/dufs-test/bbb
ln -s /nonexistent /tmp/dufs-test/aaa/sub/broken-link
touch /tmp/dufs-test/bbb/hello.txt

dufs /tmp/dufs-test --port 9999 --allow-search --allow-symlink &
sleep 1

# This finds nothing (bbb/ is silently skipped because aaa/ is walked first
# and the broken symlink inside it aborts the walk):
curl -s "http://localhost:9999/?q=hello"

# Normal listing works fine:
curl -s "http://localhost:9999/"

Expected behavior

Search should skip entries that produce errors (broken symlinks, permission errors, etc.) and continue walking the remaining directory tree.

Suggested fix

Replace:

while let Some(Ok(entry)) = it.next() {

With something like:

while let Some(result) = it.next() {
    let entry = match result {
        Ok(entry) => entry,
        Err(_) => continue,
    };

Environment

  • dufs version: 0.45.0 (also reproduced on 0.44.0)
  • OS: Ubuntu 24.04 (inside an Incus/LXC container)
  • Filesystem: ZFS
  • The broken symlinks were Python venv bin/python links pointing to a non-existent interpreter path
Originally created by @dominikroblek on GitHub (Apr 9, 2026). Original GitHub issue: https://github.com/sigoden/dufs/issues/683 ## Description When `--allow-search` is enabled and the directory tree contains broken symlinks, search (`?q=...`) silently stops returning results for sibling directories that come after the directory containing the broken symlinks in filesystem order. ## Root cause In `server.rs`, `collect_dir_entries` uses: ```rust while let Some(Ok(entry)) = it.next() { ``` `WalkDir::new(&dir).follow_links(true)` produces `Some(Err(...))` when it encounters a broken symlink. The `while let Some(Ok(entry))` pattern doesn't match `Some(Err(...))`, so the entire loop exits — skipping all remaining entries in the walk. ## Steps to reproduce ```bash mkdir -p /tmp/dufs-test/aaa/sub /tmp/dufs-test/bbb ln -s /nonexistent /tmp/dufs-test/aaa/sub/broken-link touch /tmp/dufs-test/bbb/hello.txt dufs /tmp/dufs-test --port 9999 --allow-search --allow-symlink & sleep 1 # This finds nothing (bbb/ is silently skipped because aaa/ is walked first # and the broken symlink inside it aborts the walk): curl -s "http://localhost:9999/?q=hello" # Normal listing works fine: curl -s "http://localhost:9999/" ``` ## Expected behavior Search should skip entries that produce errors (broken symlinks, permission errors, etc.) and continue walking the remaining directory tree. ## Suggested fix Replace: ```rust while let Some(Ok(entry)) = it.next() { ``` With something like: ```rust while let Some(result) = it.next() { let entry = match result { Ok(entry) => entry, Err(_) => continue, }; ``` ## Environment - dufs version: 0.45.0 (also reproduced on 0.44.0) - OS: Ubuntu 24.04 (inside an Incus/LXC container) - Filesystem: ZFS - The broken symlinks were Python venv `bin/python` links pointing to a non-existent interpreter path
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sigoden/dufs#1770