Subject: | dircopy doesn't copy contents of non-writeable directories |
Date: | Fri, 26 Aug 2016 20:05:14 +0000 |
To: | "bug-File-Copy-Recursive [...] rt.cpan.org" <bug-File-Copy-Recursive [...] rt.cpan.org> |
From: | Gordon Weekly <Gordon.Weekly [...] mathworks.com> |
Hi,
It seems version 0.38 does not copy contents of non-writeable directories.
Distribution name and version: File-Copy-Recursive-0.38
Perl version: v5.20.2 built for x86_64-linux-thread-multi
uname -a:
Linux machine 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64 GNU/Linux
Reproduction steps:
% cd /tmp
% mkdir src
% mkdir src/top
% mkdir src/top/sub1
% touch src/top/sub1/file1.1
% echo hello-1.2 > src/top/sub1/file1.2
% mkdir src/top/sub2
% touch src/top/sub2/file2.1
% echo hello-2.2 > src/top/sub2/file2.2
% chmod -w src/top/sub2
% perl -MFile::Copy::Recursive'(dircopy)' -de0
DB<1> x dircopy( '/tmp/src', '/tmp/dest' )
Note that /tmp/dest/top/sub2 is an empty directory - ought to have 2 files
Patch:
--- Recursive.pm
+++ /tmp/Recursive.pm
@@ -218,6 +218,6 @@
$DirPerms = oct($DirPerms) if substr($DirPerms,0,1) eq '0';
mkdir($end,$DirPerms) or return if !-d $end;
- chmod scalar((stat($str))[2]), $end if $KeepMode;
if($MaxDepth && $MaxDepth =~ m/^\d+$/ && $level >= $MaxDepth) {
return ($filen,$dirn,$level) if wantarray;
return $filen;
@@ -268,4 +268,5 @@
}
}
+ chmod scalar((stat($str))[2]), $end if $KeepMode;
1;
};
Note: You may want to also deal with the early returns (eg: line 222) as they may want the chmod's too.
Thank you,
-Gordon Weekly