Repository navigation
Conversation
|
Thanks for the fix and the regression tests. I found one blocking issue in the traversal. Removing directories from visited_directories after recursion prevents ancestor cycles, but allows the same target to be traversed again through other aliases. In a local reproduction against 72c83e2, discovery returned 4,096 paths for one physical file. Please retain visited directory targets for the entire folder walk and update the duplicate-target test accordingly. We also need a regression test where multiple symlink paths converge on the same directories, asserting that each target is visited once. The current test explicitly accepts duplicate results, so it doesn't catch this case. Once that's addressed, I can review the updated implementation and run the required checks. |
66HEX
left a comment
There was a problem hiding this comment.
Thanks for working on this!
There is an issue with backtracking visited_directories.remove(&canonical_path): while it prevents direct symlink cycles, it still allows exponential traversal blowup on symlink DAGs (e.g., diamond symlink structures can cause
Notice that the new test is even named discover_supported_source_paths_skips_symlink_loops_and_duplicate_targets, yet currently asserts that clip.mp4 is returned three times.
If we keep visited_directories as a traversal-wide visited set (i.e. remove visited_directories.remove(&canonical_path)), it both prevents DAG DoS and avoids duplicate queue entries from symlinked directories. Could you update the traversal and test accordingly?
Fixes #252.
Choosing a folder containing a symlinked subdirectory added nothing from the symlink target.
supported_source_paths_in_directoryinframe-app/src/file_filters.rsusedDirEntry::file_type(), which does not follow symlinks, so a symlinked directory reported neitheris_dir()noris_file()and was silently skipped (same for symlinked files).The fix switches the traversal to
std::fs::metadata(), which follows symlinks, so linked directories are walked and linked files are collected under the path the user actually picked. Cycle protection uses a stack-scoped set of canonical directory paths: a directory whose canonical path is already on the current walk is not re-entered, so symlink loops terminate. A directory reached through a different symlink path is still traversed, so the same files can legitimately appear under each distinct path (matching the existing no-dedupe behaviour ofdiscover_supported_source_paths).Proof
Base:
8fe5aa17aa86ec8b7326b3b93584491d9d11a14c(master).Repro (tests only, before the fix) —
cargo test -p frame-app file_filters:discover_supported_source_paths_follows_symlinked_directories(got[], expected[<root>/linked/clip.mp4]) anddiscover_supported_source_paths_skips_symlink_loops_and_duplicate_targets(got only[<root>/target/clip.mp4], expected thelinked,also-linkedandtargetpaths).Pass after — same command: 16 passed, 0 failed.
Control case: the existing
discover_supported_source_paths_expands_directories_recursivelytest still passes, as do all other pre-existingfile_filterstests.Regression scope:
cargo test -p frame-app --lib: 1158 passed, 1 failed. The one failure,app::accessibility_ui_tests::crop_resize_and_scrollbar_drags_start_outside_the_visible_markers(expanded area did not start a drag,accessibility_ui_tests.rs:489), fails identically on the clean base commit, so it is pre-existing and unrelated to this change.cargo test -p frame-app --test gpui_queue: 2 passed.cargo fmt --check -p frame-app: clean.cargo clippy -p frame-app --lib --tests: no warnings.framebin test targets initially failed to link in this sandbox (unable to find library -lxkbcommon-x11); installinglibxkbcommon-x11-devlocally fixed that, and the fullcargo test -p frame-app file_filtersrun above (lib + bin + integration targets) passes.Diff scope
1 file,
frame-app/src/file_filters.rs(+78/−6), in 2 commits: regression tests first, then the fix. The new tests are#[cfg(unix)](they create symlinks viastd::os::unix::fs::symlink); the fix itself only usesstd::fsAPIs and is platform-independent.