Skip to content

Commit

Permalink
Do not ignore symlinks pointing to regular files
Browse files Browse the repository at this point in the history
  • Loading branch information
morenol committed Jan 14, 2022
1 parent 0faae41 commit 93a9bd1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/inotify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ impl EventLoop {
.into_iter()
.filter_map(filter_dir)
{
self.add_single_watch(entry.path().to_path_buf(), is_recursive, watch_self)?;
self.add_single_watch(entry, is_recursive, watch_self)?;

This comment has been minimized.

Copy link
@0xpr03

0xpr03 Jan 14, 2022

why is that necessary ? to resolve the real file ?

This comment has been minimized.

Copy link
@morenol

morenol Jan 14, 2022

Author Owner

Yes, the change in the line 568 is to resolve the real file so we call add_single_watch on them

watch_self = false;
}

Expand Down Expand Up @@ -557,13 +557,16 @@ impl EventLoop {
}

/// return `DirEntry` when it is a directory
fn filter_dir(e: walkdir::Result<walkdir::DirEntry>) -> Option<walkdir::DirEntry> {
fn filter_dir(e: walkdir::Result<walkdir::DirEntry>) -> Option<PathBuf> {
if let Ok(e) = e {
if let Ok(metadata) = e.metadata() {
if metadata.is_dir() {
return Some(e);
return Some(e.path().to_path_buf());
}
}
if e.path_is_symlink() {
return std::fs::canonicalize(e.path()).ok();
}
}
None
}
Expand Down

0 comments on commit 93a9bd1

Please sign in to comment.