Skip to content

Commit

Permalink
Do not stat a path if not recursive. (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
stuhood authored Jul 16, 2020
1 parent 6b41307 commit 05da071
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
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() {
return self.add_single_watch(path, false, true);
}

Expand Down

0 comments on commit 05da071

Please sign in to comment.