-
Notifications
You must be signed in to change notification settings - Fork 555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File::Find::fullname sometimes undef for plain files #13379
Comments
From @jimavThis is a bug report for perl from james_avera@yahoo.com, File::Find with follow=>1 sometimes sets File::Find::fullname to This occurs if a symlink elsewhere in the tree refers to the plain If bug will not be fixed, or if it is not really a bug, then it would #!/usr/bin/perl my $d = "/tmp/testdir"; # this one triggers the bug find({ #dangling_symlinks => 1, Flags: Site configuration information for perl 5.14.2: Configured by Debian Project at Thu Jul 18 22:04:35 UTC 2013. Summary of my perl5 (revision 5 version 14 subversion 2) configuration: Locally applied patches: @INC for perl 5.14.2: Environment for perl 5.14.2: |
From @jimavForgot to mention that File::Find::VERSION = 1.19 |
From victor@vsespb.ruattaching patch. tested only under linux. On Sun Oct 27 16:21:21 2013, jimav wrote:
|
From victor@vsespb.ru0001-File-Find-fullname-was-not-set-for-file-is-there-was.patchFrom 031b3d68afbe80f00f8fd3fe861e69d94ec0e80b Mon Sep 17 00:00:00 2001
From: Victor <victor@vsespb.ru>
Date: Tue, 29 Oct 2013 15:57:43 +0400
Subject: [PATCH] File::Find::fullname was not set for file is there was a
symlink pointing to this file, RT#120388
from documentation: "If the link is a dangling symbolic link, then fullname will be set to undef."
Follow_SymLink can return undef if it's not a symlink, need explicitly check that we have a symlink
and that's a dangling symlink before setting File::Find::fullname to undef.
Also this patch sets fullname to correct value.
---
ext/File-Find/lib/File/Find.pm | 5 +++--
ext/File-Find/t/find.t | 26 ++++++++++++++++++++++++--
2 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/ext/File-Find/lib/File/Find.pm b/ext/File-Find/lib/File/Find.pm
index a179998..ff3aadc 100644
--- a/ext/File-Find/lib/File/Find.pm
+++ b/ext/File-Find/lib/File/Find.pm
@@ -982,14 +982,15 @@ sub _find_dir_symlnk($$$) {
# ignore if invalid symlink
unless (defined $new_loc) {
if (!defined -l _ && $dangling_symlinks) {
+ $fullname = undef;
if (ref $dangling_symlinks eq 'CODE') {
$dangling_symlinks->($FN, $dir_pref);
} else {
warnings::warnif "$dir_pref$FN is a dangling symbolic link\n";
}
+ } else {
+ $fullname = $loc_pref . $FN;
}
-
- $fullname = undef;
$name = $dir_pref . $FN;
$_ = ($no_chdir ? $name : $FN);
{ $wanted_callback->() };
diff --git a/ext/File-Find/t/find.t b/ext/File-Find/t/find.t
index 62ec81e..13b4557 100644
--- a/ext/File-Find/t/find.t
+++ b/ext/File-Find/t/find.t
@@ -29,7 +29,7 @@ BEGIN {
}
my $test_count = 98;
-$test_count += 119 if $symlink_exists;
+$test_count += 127 if $symlink_exists;
$test_count += 26 if $^O eq 'MSWin32';
$test_count += 2 if $^O eq 'MSWin32' and $symlink_exists;
@@ -93,11 +93,15 @@ sub cleanup {
file_path('fa', 'fac', 'faca'),
file_path('fb', 'fb_ord'),
file_path('fb', 'fba', 'fba_ord'),
- file_path('fb', 'fbc', 'fbca');
+ file_path('fb', 'fbc', 'fbca'),
+ file_path('fa', 'fax', 'faz'),
+ file_path('fa', 'fay');
+
rmdir dir_path('fa', 'faa');
rmdir dir_path('fa', 'fab', 'faba');
rmdir dir_path('fa', 'fab');
rmdir dir_path('fa', 'fac');
+ rmdir dir_path('fa', 'fax');
rmdir dir_path('fa');
rmdir dir_path('fb', 'fba');
rmdir dir_path('fb', 'fbc');
@@ -880,6 +884,24 @@ if ($symlink_exists) { # Issue 68260
Check (!$dangling_symlink);
}
+if ($symlink_exists) { # perl #120388
+ print "# BUG 120388\n";
+ MkDir (dir_path ('fa', 'fax'), 0770);
+ touch (file_path ('fa', 'fax', 'faz'));
+ CheckDie (symlink ( file_path ('..', 'fa', 'fax', 'faz'), file_path ('fa', 'fay') ));
+ my @seen;
+ File::Find::find( {wanted => sub {
+ if (/^fa[yz]$/) {
+ push @seen, $_;
+ Check(-e $File::Find::fullname);
+ my $subdir = file_path qw/for_find fa fax faz/;
+ Check $File::Find::fullname =~ m!\Q$subdir\E$!;
+ }
+ }, follow => 1}, topdir('fa'));
+ Check(join(',', @seen) eq 'fay,faz'); # make sure "fay"(symlink) found before "faz"(real file), otherwise test invalid
+}
+
+
print "# RT 59750\n";
MkDir( dir_path('fc'), 0770 );
MkDir( dir_path('fc', 'fca'), 0770 );
--
1.7.9.5
|
The RT System itself - Status changed from 'new' to 'open' |
From @jkeenanOn Tue Oct 29 05:05:31 2013, vsespb wrote:
I tried applying the patch on Darwin/PPC. The patch applied mostly cleanly (1 "whitespace added" error). But I got two failures in the test file. Unfortunately, since none of the tests in ext/File-Find/t/find.t have descriptions, I don't yet have any diagnosis of the problem. ... Test Summary Report ../ext/File-Find/t/find.t (Wstat: 0 Tests: 225 Failed: 2) |
From victor@vsespb.ru210 and 211 are assertions Check(-e $File::Find::fullname); for filename "faz" I would get same failures if I apply fix for tests but do not apply fix to I have no idea why it's failed on your system. 2013/11/10 James E Keenan via RT <perlbug-followup@perl.org>
|
From @jkeenanOn Sat Nov 09 18:56:57 2013, jkeenan wrote:
This lack of test descriptions spurred me to create and work on RT #120503. The work from that ticket has now been committed to blead. I have adapted Victor's patch to use the testing syntax now used in ext/File-Find/t/find.t and tested it successfully on both Linux and Darwin. I will give the #120503 changes a day or two to settle in. Then I will apply the adapted patch to blead. Thank you very much. |
From @jkeenanOn Sun Nov 17 06:05:25 2013, jkeenan wrote:
I applied the patch to blead in commit: Victor, please make sure I've correctly translated the syntax of your patches to the new testing subroutines in ext/File-Find/t/find.t. James Avera, please make sure these patches fix your original problem. Assuming all is well, I will close this ticket within 3 days. Thank you very much. |
From victor@vsespb.ru2013/11/19 James E Keenan via RT <perlbug-followup@perl.org>
I've checked, all looks ok.
|
From @jkeenanOn Mon Nov 18 23:36:59 2013, vsespb wrote:
Thanks; marking ticket resolved. |
@jkeenan - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#120388 (status was 'resolved')
Searchable as RT120388$
The text was updated successfully, but these errors were encountered: