Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not stat a path if not recursive. #256

Merged
merged 2 commits into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
- CHANGE: Make `Notice` events opt-in.
- CHANGE: Remove `Sender`s from watcher API in favour of `EventFn` [#214]
- META: The project maintainers have changed from @passcod to notify-rs.
- CHANGE: Avoid stating the watched path for non-recursive watches with inotify [#256]

[#256]: https://github.com/notify-rs/notify/pull/256

## 5.0.0-pre.3 (2020-06-22)

Expand Down
6 changes: 3 additions & 3 deletions src/inotify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,9 @@ impl EventLoop {
}

fn add_watch(&mut self, path: PathBuf, is_recursive: bool, mut watch_self: bool) -> Result<()> {
let metadata = metadata(&path).map_err(Error::io)?;

if !metadata.is_dir() || !is_recursive {
// If the watch is not recursive, or if we determine (by stat'ing the path to get its
// metadata) that the watched path is not a directory, add a single path watch.
if !is_recursive || !metadata(&path).map_err(Error::io)?.is_dir() {
JohnTitor marked this conversation as resolved.
Show resolved Hide resolved
return self.add_single_watch(path, false, true);
}

Expand Down