Repository navigation
fix(tools): canonicalize watch root so relative paths receive events - #3115
Open
amitcoder79 wants to merge 1 commit into
Open
amitcoder79 wants to merge 1 commit into
amitcoder79 wants to merge 1 commit into
Conversation
The notify crate delivers events with absolute paths from the OS, but notified() stored the root path as given. A relative root never matched absolute event paths in Filter::keeps(), silently dropping every event. Canonicalize the root via real_path() before storing it, so strip_prefix and equality checks work regardless of how the caller spelled the path. Fixes 0xPlaygrounds#3109
7 tasks done
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.
Fixes #3109
Local.watch(relative_path, ...)returnedOk(Watch)but silently dropped every event. The same path made absolute worked correctly.Root cause
notified()stored the caller-provided root as-is into theFilter. Thenotifycrate's OS-level watchers (inotify, FSEvents) deliver events with absolute paths.Filter::keeps()then compared:absolute_event_path == relative_stored_path→ alwaysfalseabsolute_event_path.strip_prefix(relative_root)→ alwaysErr→falseEvery event was silently rejected, and since
send_batchesonly sends non-empty batches, nothing ever reached theWatchstream.Fix
Canonicalize
rootat the top ofnotified()using the existingcrate::fs::real_path, which callsstd::path::absoluteand resolves symlinks. This ensures the stored root matches event paths regardless of how the caller spelled the path.What changed
One file, 5 added lines:
Testing
All 5 existing watch tests pass. The fix is exercised by any test or caller that passes a relative path to
Local.watch.Cassettes
Not applicable (no provider interaction).
Changelog
Local.watchnow correctly delivers events when called with relative paths