Subject: | warnings with broken symbolic links |
Under ext4, scanning a directory with a broken symlink leads to a
warning:
```
Use of uninitialized value in numeric ne (!=) at Notify.pm line 118
Use of uninitialized value in numeric ne (!=) at Notify.pm line 119
```
the reason seems to be that, for those cases, '@stat' in the the
function '_stat' is empty '()' and, consequently, the keys 'mtype' and
'size' take undefined values.
a quick-n-dirty patch for Notify.pm is attached.
Environment:
This is perl, v5.10.1 (*) built for x86_64-linux-gnu-thread-multi
Debian 6.0.3 (ext4 partition)
Subject: | notify.patch |
72,73c72,73
< my %files = map { $_ => 1 } File::Find::Rule->in(@paths);
< %files = map { abs_path($_) => _stat($_) } keys %files;
---
> # (i didn't get it...)
> my @files = File::Find::Rule->in(@paths);
75c75,84
< return \%files;
---
> my $fs_stats = {};
> foreach my $file_path (@files) {
> # _stat() returns undef if no stats can be retrieved,
> # as with broken symlinks under ext4 (and possibly others).
> if (my $file_stats = _stat($file_path)) {
> $fs_stats->{abs_path($file_path)} = $file_stats;
> }
> }
>
> return $fs_stats;
123a133,134
> # Returns undefined if no stats can be retrieved, as it happens with broken
> # symlinks (at least under ext4).
127,134c138,147
< my @stat = stat $path;
< return {
< path => $path,
< mtime => $stat[9],
< size => $stat[7],
< is_dir => -d _,
< };
<
---
> if (my @stat = stat $path ) {
> return {
> path => $path,
> mtime => $stat[9],
> size => $stat[7],
> is_dir => -d _,
> };
> } else {
> return undef;
> }
215c228
< given directories and execute a callback when a modification is detected.
---
> given directories and execute a callback when a modification is detected.
222c235
< =item dirs
---
> =item dirs
263c276
< encouraged as the L</Fallback> implement is very inefficient, but it
---
> encouraged as the L</Fallback> implement is very inefficient, but it
308,309c321,322
< This is not slight against the authors of those modules. Both are well
< respected, are certainly finer coders than I am, and built modules which
---
> This is not slight against the authors of those modules. Both are well
> respected, are certainly finer coders than I am, and built modules which