Closed djerius closed 3 years ago
Further note, since I can't replicate this outside of the one host, I can only raise this as a concern, so that if you do see other bug reports there's some added history.
Unless File::Find does a run-time test to see if directory link counts are accurate indications of the number of directories, I don't see much that can be done.
$File::Find::dont_use_nlink
always defaults to 1 since Perl 5.30. On older Perls you can set this manually. See https://perldoc.perl.org/File::Find#CAVEAT and https://github.com/perl/perl5/issues/16759.
$File::Find::dont_use_nlink always defaults to 1 since Perl 5.30. On older Perls you can set this manually. See https://perldoc.perl.org/File::Find#CAVEAT and #16759.
Yeah, it was an optimization that kept biting us in the tail
The incorrect directory link count was caused by a mis-configured system.
Anyway, glad to hear that had I upgraded to 5.30 I wouldn't have had this problem (but then I wouldn't have fixed the underlying problem).
The incorrect directory link count was caused by a mis-configured system.
Anyway, glad to hear that had I upgraded to 5.30 I wouldn't have had this problem (but then I wouldn't have fixed the underlying problem).
If I understand the comments in this ticket correctly, the original problem is not a problem in supported versions of Perl. Hence, this ticket should be closable. Comments?
Thank you very much. Jim Keenan
The incorrect directory link count was caused by a mis-configured system. Anyway, glad to hear that had I upgraded to 5.30 I wouldn't have had this problem (but then I wouldn't have fixed the underlying problem).
If I understand the comments in this ticket correctly, the original problem is not a problem in supported versions of Perl. Hence, this ticket should be closable. Comments?
No one has indicated this is not closable and no one has commented further. Closing ticket.
Thank you very much. Jim Keenan
Anyway, glad to hear that had I upgraded to 5.30 I wouldn't have had this problem (but then I wouldn't have fixed the underlying problem).
You don't need to upgrade to perl 5.30 -- all you need to do is update File::Find to at least version 1.35 (it's available separately on cpan), or set local $File::Find::dont_use_link = 1;
before using File::Find functions.
Module: File::Find
Description
tldr;
File::Find
to believe either that there are no subdirectories (if nlinks==2) or that there are fewer subdirectories present, producing incorrect results.Caveats
Steps to Reproduce As mentioned above, I've found it hard to duplicate, but here's my setup. The Dockerfile:
At the command line:
The link count is 3. `
Note that
File::Find
descends into the apt directory. Now, modify the directoryThe link count has decreased from 3 to 2.
and
File::Find
no longer descends into aptAnalysis
File::Find
may use the link count of a directory to determine the number of subdirectories. This is controlled by the $File::Find::dont_use_nlink variable, which depends upon a configuration variable:(From
File::Find
version 1.34). On Debian 10,Later, in
_find_dir
, the link count to the directory is used to determine if there are any subdirectories, as well as the number of subdirectories. As Perl is configured to trust the link count, the revised link count of 2 after adding the file to the directory convincesFile::Find
that there are no subdirectories, when in fact there are.Expected behavior
I expect File::Find to traverse all of the subdirectories
Perl configuration