Subject: | Improve diagnostics from LWP::UserAgent::mirror |
A similar issue is described in #48236. I happened to come across the
same problem and found a different spot where the diagnostics can be
improved. Because the user had no write permissions to the directory the
tmpfile was not even written and the stat() call was unsuccessful. I
suspect this has a corollary in some unsuccessful close() further up the
chain.
The patch seems orthogonal to Slaven's patch in 48236, so I make this a
new RT ticket.
Subject: | lwp-useragent-diagnostics-on-stat.diff |
diff --git a/lib/LWP/UserAgent.pm b/lib/LWP/UserAgent.pm
index d932085..f773d3a 100644
--- a/lib/LWP/UserAgent.pm
+++ b/lib/LWP/UserAgent.pm
@@ -839,7 +839,8 @@ sub mirror
# If the file was not modified, "304" would returned, which
# is considered by HTTP::Status to be a "redirect", /not/ "success"
if ( $response->is_success ) {
- my $file_length = ( stat($tmpfile) )[7];
+ my @stat = stat($tmpfile) or die "Could not stat tmpfile '$tmpfile': $!";
+ my $file_length = $stat[7];
my ($content_length) = $response->header('Content-length');
if ( defined $content_length and $file_length < $content_length ) {