- my @now = stat($path) or next;
- my $prv = $watch->{$x};
- my $cb = $prv->[-1];
- my $old_ctime = $prv->[0];
- if ($old_ctime != $now[10]) {
- if (($mask & $IN_CLOSE) == $IN_CLOSE) {
- eval { $cb->() };
- } elsif ($mask & MOVED_TO_OR_CREATE) {
- opendir(my $dh, $path) or do {
- warn "W: opendir $path: $!\n";
- next;
- };
- on_new_files($dh, $cb, $path, $old_ctime);
+ my @now = stat($path);
+ if (!@now && $!{ENOENT} && ($mask & IN_DELETE_SELF)) {
+ push @$events, bless(\$path,
+ 'PublicInbox::FakeInotify::SelfGoneEvent');
+ push @watch_gone, $x;
+ delete $self->{dirlist}->{$path};
+ }
+ next if !@now;
+ my $old_ctime = $watch->{$x};
+ $watch->{$x} = $now[10];
+ next if $old_ctime == $now[10];
+ if ($mask & IN_MODIFY) {
+ push @$events,
+ bless(\$path, 'PublicInbox::FakeInotify::Event')
+ } elsif ($mask & (MOVED_TO_OR_CREATE | IN_DELETE)) {
+ if (opendir(my $dh, $path)) {
+ on_dir_change($events, $dh, $path, $old_ctime,
+ $self->{dirlist});
+ } elsif ($!{ENOENT}) {
+ push @watch_gone, $x;
+ delete $self->{dirlist}->{$path};
+ } else {
+ warn "W: opendir $path: $!\n";