Repository navigation
fix(tools): report files of a directory moved into a recursive watch - #3131
Open
1AbdullahButt wants to merge 1 commit into
Open
1AbdullahButt wants to merge 1 commit into
1AbdullahButt wants to merge 1 commit into
Conversation
The watch only rescanned a new directory for the files already in it on a Create event. On Linux notify reports a rename destination as Modify(Name(To)), so a populated directory moved into the watched tree was never rescanned and none of its files were reported. Treat rename events like creations for that rescan; the is_dir check still limits it to directories. Fixes 0xPlaygrounds#3124 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A recursive
Localwatch reported nothing when a populated directory was moved into the watched tree. Its files never appeared in a batch, even thoughfileslists them.The batching thread rescans a new directory for the files already in it, but only when the event was a creation (
created = matches!(event.kind, EventKind::Create(_))). On Linux, notify reports a rename destination asModify(Name(To)), so a moved-in directory went toFilter::keeps, which rejects directories, and its files got no events of their own. The adapter now also setscreatedforModify(ModifyKind::Name(_)). The rescan still runs only when the path is a directory, so a renamed file goes throughFilter::keepsas before, and the rename source of aBothevent no longer exists, so it isn't rescanned.This doesn't overlap #3115, which canonicalizes relative roots in the same file.
Fixes #3124
Changelog
Localwatch reports the files of a directory moved into the watched tree, including nested ones, as it already did for a directory created there.Migration
None
Testing
I ran these in a
rust:1.97(1.97.1) Linux container, since the bug needs inotify:watch::tests::a_recursive_watch_reports_the_files_of_a_directory_moved_inmovesstaging/{existing.rs,nested/deep.rs}into a watched root and expects both paths. It failed before the fix (left: []) and passes after it.cargo test -p rig-tools --lib watch::: 6 passed, 1 failed.a_relative_watch_sees_a_changefails because its fixture sits in the bind-mounted Windows checkout (target/relative to the repo), where inotify gets no events in a container. It doesn't touch this change. The other watch tests use/tmpand pass.cargo clippy -p rig-tools --all-targets: clean.rustfmt --edition 2024 --checkon both changed files: clean.Checklist:
Raw)CHANGELOG.mdorMIGRATING.md(they are generated at release)Notes
This change, its test and this description were written with Claude Code (Claude Opus 5.5).
🤖 Generated with Claude Code