Skip to content

fix(tools): report files of a directory moved into a recursive watch - #3131

Open
1AbdullahButt wants to merge 1 commit into
0xPlaygrounds:mainfrom
1AbdullahButt:fix/3124-watch-moved-in-dir
Open

1AbdullahButt wants to merge 1 commit into
0xPlaygrounds:mainfrom
1AbdullahButt:fix/3124-watch-moved-in-dir

Conversation

@1AbdullahButt

Copy link
Copy Markdown

Description

A recursive Local watch reported nothing when a populated directory was moved into the watched tree. Its files never appeared in a batch, even though files lists 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 as Modify(Name(To)), so a moved-in directory went to Filter::keeps, which rejects directories, and its files got no events of their own. The adapter now also sets created for Modify(ModifyKind::Name(_)). The rescan still runs only when the path is a directory, so a renamed file goes through Filter::keeps as before, and the rename source of a Both event no longer exists, so it isn't rescanned.

This doesn't overlap #3115, which canonicalizes relative roots in the same file.

Fixes #3124

Changelog

  • (tools) A recursive Local watch 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:

  • New test watch::tests::a_recursive_watch_reports_the_files_of_a_directory_moved_in moves staging/{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_change fails 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 /tmp and pass.
  • cargo clippy -p rig-tools --all-targets: clean.
  • rustfmt --edition 2024 --check on both changed files: clean.

Checklist:

  • I have updated READMEs and Rust docs affected by this change (the doc comment on Raw)
  • I have added tests that prove my fix is effective or that my feature works
  • I did not edit CHANGELOG.md or MIGRATING.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

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(tools): recursive watches omit files in directories moved into the watched tree

1 participant