Skip Menu |

This queue is for tickets about the File-Copy-Recursive CPAN distribution.

Report information
The Basics
Id: 12291
Status: resolved
Priority: 0/
Queue: File-Copy-Recursive

People
Owner: Nobody in particular
Requestors: Troy.D.Goodson [...] jpl.nasa.gov
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.05
Fixed in: 0.06



Subject: doesn't preserve symbolic links
I think that dircopy in this module should copy symbolic links as symbolic links instead of copying the target of the symbolic link. If you're just calling fcopy, then the functionality is very specific and it's clear what should happen. The symbolic link's target should be copied to the destination. However, when you use dircopy, it's not obvious what the module will do with symbolic links. I suggest that the common expectation is that symbolic links get preserved, but dircopy doesn't preserve them. for exmaple, on a Unix shell: cd ~/testdir ln -s bunchOfData tinylink Here, "tinylink" is a symbolic link of "bunchOfData" and its size reflects that. Then, in perl, do dircopy("testdir","copytestdir") and you'll find that "copytestdir/tinylink" is a file with the same contents as "bunchOfData" I have supplied a patch which, I think, appropriately implements the preservation of symbolic links in dircopy. This is perl, v5.8.0 built for i386-linux-thread-multi (with 1 registered patch, see perl -V for more detail) % uname -a Linux mycomputer 2.4.20-30.8.legacy #1 Fri Feb 20 17:47:48 PST 2004 i686 i686 i386 GNU/Linux
*** orig/File/Copy/Recursive.pm Mon Jan 24 17:10:49 2005 --- File/Copy/Recursive.pm Thu Apr 14 18:01:55 2005 *************** *** 33,40 **** --- 33,47 ---- my $level = 0; my $filen = 0; my $dirn = 0; + # check if this system can symlink + my $can_symlink = eval { symlink("",""); 1 }; + unless ($can_symlink) { + warn "this system can't make symbolic links, files will be copied", + " instead of linked.\n"; + } + my $recurs; #must be my()ed before sub {} since it calls itself $recurs = sub { my ($str,$end,$buf) = @_; $filen++ if $end eq $baseend; *************** *** 58,65 **** --- 65,75 ---- $recurs->($org,$new,$buf) if defined $buf; $recurs->($org,$new) if !defined $buf; $filen++; $dirn++; + } elsif ((-l $org) and $can_symlink) { + symlink( readlink($org), $new ); + $filen++; } else { copy($org,$new,$buf) or return if defined $buf; copy($org,$new) or return if !defined $buf; chmod scalar((stat($org))[2]), $new if $KeepMode;
[guest - Thu Apr 14 21:25:42 2005]: Show quoted text
> I think that dircopy in this module should copy symbolic links > as symbolic links instead of copying the target of the > symbolic link.
I was hoping that File::Copy's copy() would handle that but apparently it does not. Thanks for the suggestion and patch, I've not used your patch but it is appreciated. Show quoted text
> If you're just calling fcopy, then the functionality is > very specific and it's clear what should happen. The > symbolic link's target should be copied to the destination.
In version 0.06 SymLinks will be preserved if supported and can be over ridden by the user. See the the POD in 0.06 (uploading now) for details. Thanks