Skip Menu |

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

Report information
The Basics
Id: 13763
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.06
Fixed in: 0.07



Subject: dircopy does not report problems from 'copy' or 'symlink'
It appears that when File::Copy's copy() returns with an error, or if symlink() returns with an error, dircopy() does not. I ran into this problem when I tried to copy a directory structure that included a file for which I didn't have read privileges. It took a good bit of work before I discovered that the problem had to do with privileges and which file was the culprit. I haven't looked into the 'right' way for a subroutine to report such errors, but I think the following will work appropriately. Instead of copy($org,$new) or return if !defined $buf; use copy($org,$new) or return "couldn't copy $org to $new: $!" if !defined $buf; and, instead of opendir DIRH, $str or return; use opendir DIRH, $str or return "couldn't opendir $str: $!"; for example. The messages may printed as warnings, which I think is consistent with the design of dircopy, by using if (my $recurs_out = $recurs->(@_)) { warn $recurs_out,"\n"; } (there must be a better way...) instead of just $recurs->(@_); Looking at the code for File::Copy::Recursive, it appears that fcopy has a similar problem, but fcopy has a different structure so that probably deserves its own bug entry.
[guest - Mon Jul 18 18:42:14 2005]: Show quoted text
> It appears that when File::Copy's copy() returns with an error, > or if symlink() returns with an error, dircopy() does not.
It will now, $recurs->(@_); needed to be $recurs->(@_) or return; Show quoted text
> I ran into this problem when I tried to copy a directory > structure that included a file for which I didn't have > read privileges. It took a good bit of work before I > discovered that the problem had to do with privileges and > which file was the culprit. > > I haven't looked into the 'right' way for a subroutine to report > such errors, but I think the following will work appropriately. > > Instead of > > copy($org,$new) or return if !defined $buf; > > use > > copy($org,$new) or return "couldn't copy $org to $new: $!" if > !defined $buf;
That is not good because it woudl be returning true so dircopy($d1,$d2) or wanr $!; woudl not work... Show quoted text
> and, instead of > > opendir DIRH, $str or return; > > use > > opendir DIRH, $str or return "couldn't opendir $str: $!";
Same thing as above... Show quoted text
> for example. > > The messages may printed as warnings, which I think is consistent > with the design of dircopy, by using > > if (my $recurs_out = $recurs->(@_)) { > warn $recurs_out,"\n"; > }
What if someone wants to die if there are problems or just wants a silent copy, ignoring any problems? i chose on purpose to simply return when built in functions or File::Copy::copy fail so the end user can choose how to handle it and can use the system set error $! Show quoted text
> (there must be a better way...) instead of just > > $recurs->(@_); > > Looking at the code for File::Copy::Recursive, it appears that fcopy > has a similar problem, but fcopy has a different structure so that > probably deserves its own bug entry.
It returns is symlink or File::Copy::copy fail, it is up to you/perl how $! is set/used. The fix is in 0.07 which I am uploading in a minute :)