Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Filesys-Notify-Simple CPAN distribution.

Report information
The Basics
Id: 74626
Status: open
Priority: 0/
Queue: Filesys-Notify-Simple

People
Owner: Nobody in particular
Requestors: carlosnunomota [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: _file_scan on Linux::Inotify2 wont monitor empty dirs
If you declare a folder to watch that has empty subfolders those subfolders will not be monitored since the _file_scan function is discarding them. I made a hack to fix this, don't know if it is good code, probably it could be a lot better but I am not very familiar with File::Find, the fix I did was: sub _dir_empty { my ($path) = @_; return 0 unless -d $path; opendir my($dir), $path; my @content = grep {$_ !~ /^\.\.?$/} readdir $dir; closedir($dir); return scalar(@content) ? 0 : 1; } sub _full_scan { my @path = @_; require File::Find; my %map; for my $path (@path) { my $fp = eval { Cwd::realpath($path) } or next; File::Find::finddepth({ wanted => sub { my $fullname = $File::Find::fullname || File::Spec->rel2abs($File::Find::name); my $stat = _stat($fullname); $map{Cwd::realpath($File::Find::dir)}{$fullname} = _stat($fullname); #FIX FOR EMPTY DIRS if (_dir_empty($fullname)) { $map{$fullname}{$fullname} = {}; } }, follow_fast => 1, follow_skip => 2, no_chdir => 1, }, @path); # remove root entry delete $map{$fp}{$fp}; } return \%map; }
Subject: Re: [rt.cpan.org #74626] _file_scan on Linux::Inotify2 wont monitor empty dirs
Date: Thu, 2 Feb 2012 08:46:06 -0800
To: bug-Filesys-Notify-Simple [...] rt.cpan.org
From: Tatsuhiko Miyagawa <miyagawa [...] gmail.com>
Open a pull request on github. On Feb 2, 2012 4:56 AM, "Nuno Mota via RT" < bug-Filesys-Notify-Simple@rt.cpan.org> wrote: Show quoted text
> Thu Feb 02 07:56:30 2012: Request 74626 was acted upon. > Transaction: Ticket created by cnmota > Queue: Filesys-Notify-Simple > Subject: _file_scan on Linux::Inotify2 wont monitor empty dirs > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: carlosnunomota@gmail.com > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=74626 > > > > If you declare a folder to watch that has empty subfolders those > subfolders will not be monitored since the _file_scan function is > discarding them. > > I made a hack to fix this, don't know if it is good code, probably it > could be a lot better but I am not very familiar with File::Find, the > fix I did was: > > sub _dir_empty { > my ($path) = @_; > > return 0 unless -d $path; > > opendir my($dir), $path; > my @content = grep {$_ !~ /^\.\.?$/} readdir $dir; > closedir($dir); > > return scalar(@content) ? 0 : 1; > } > > sub _full_scan { > my @path = @_; > require File::Find; > > my %map; > for my $path (@path) { > my $fp = eval { Cwd::realpath($path) } or next; > File::Find::finddepth({ > wanted => sub { > my $fullname = $File::Find::fullname || > File::Spec->rel2abs($File::Find::name); > my $stat = _stat($fullname); > $map{Cwd::realpath($File::Find::dir)}{$fullname} = > _stat($fullname); > > #FIX FOR EMPTY DIRS > if (_dir_empty($fullname)) { > $map{$fullname}{$fullname} = {}; > } > }, > follow_fast => 1, > follow_skip => 2, > no_chdir => 1, > }, @path); > > # remove root entry > delete $map{$fp}{$fp}; > } > > return \%map; > } > > >