Skip to content

fix(poll): return an error when watching a nonexistent path - #1001

Open
YuEfSaEDU wants to merge 1 commit into
notify-rs:mainfrom
YuEfSaEDU:fix/pollwatcher-nonexistent-path-error
Open

YuEfSaEDU wants to merge 1 commit into
notify-rs:mainfrom
YuEfSaEDU:fix/pollwatcher-nonexistent-path-error

Conversation

@YuEfSaEDU

Copy link
Copy Markdown

PollWatcher's watch() returned Ok(()) for paths that cannot be stat-ed because the fs::metadata failure inside WatchData::new was folded into an Option that watch_inner silently ignored, violating the documented Watcher::watch/watch_with contract that nonexistent paths yield an error.

This change threads the error through build_watch_data and watch_inner, mapping it with the existing Error::io_watch helper so io::ErrorKind::NotFound surfaces as ErrorKind::PathNotFound (with the requested path attached) and other io failures as ErrorKind::Io, matching how the inotify and FSEvents backends already behave. Runtime polling semantics are unchanged: an existing watch whose root later disappears is kept and reports scan errors as events.

Adds poll-backend unit tests covering the nonexistent-path error and successful watches of an existing file and directory, plus a changelog entry.

Fixes #998

PollWatcher::watch returned Ok(()) for a path that could not be
stat-ed: the fs::metadata failure inside WatchData::new was folded
into an Option that watch_inner ignored, so the watch was silently
skipped. Propagate the error through build_watch_data and watch_inner
instead, mapping it with Error::io_watch so a missing path surfaces as
ErrorKind::PathNotFound, matching the other backends.

Fixes notify-rs#998
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]: PollWatcher fails silently if path does not exist

2 participants