blib/lib/CPAN/FTP.pm

filter: Statementstmt 18.1% 250 / 1377 Branchbran 10.5% 95 / 900 Conditioncond 9.4% 39 / 412 MC/DCmcdc 2.4% 6 / 244 Subroutinesub 42.5% 23 / 54 Podpod 0.0% 0 / 26 totaltotal 13.7% 413 / 3013 CC 629 SCAR 68.3
CC
629
Cov
14%
hostdleasy
3090.5
hostdleasy
3090.5
localize_1995ff
1030.8
CRAP 925.8
↑ Summary blib/lib/CPAN.pm »
1 # -*- Mode: cperl; coding: utf-8; cperl-indent-level: 4 -*-
2 # vim: ts=4 sts=4 sw=4:
3 package CPAN::FTP;
4 26 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 26 ▶use Errno ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 26 ▶use Fcntl qw(:flock);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 26 ▶use File::Basename qw(dirname);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 26 ▶use File::Path qw(mkpath);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 26 ▶use CPAN::FTP::netrc;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 26 ▶use vars qw($connect_to_internet_ok $Ua $Thesite $ThesiteURL $Themethod);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 26 @CPAN::FTP::ISA = qw(CPAN::Debug);
14  
15 26 ▶use vars qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
16 $VERSION
17 26 );
18 26 $VERSION = "5.5018";
19  
20 48 ▶sub _plus_append_open {
Subroutine _plus_append_open: called CC=5 SCAR=29.7
21 0 ▶ my($fh, $file) = @_;
Subroutine _plus_append_open: not called CC=5 SCAR=29.7
22 0 my $parent_dir = dirname $file;
23 0 mkpath $parent_dir;
24 0 my($cnt);
25 0 ▶ until (open $fh, "+>>$file") {
Branch: 2 branches
BranchTrueFalseTotal
unless (open $fh, "+>>$file") 0 48 48
unless (open $fh, "+>>$file") 0 0 0
26 0 ▶ next if exists &Errno::EAGAIN && $! == &Errno::EAGAIN; # don't increment on EAGAIN
Branch: 2 branches
BranchTrueFalseTotal
if exists &Errno::EAGAIN and $! == &Errno::EAGAIN 0 0 0
if exists &Errno::EAGAIN and $! == &Errno::EAGAIN 0 0 0
Condition0%0/6
exists &Errno::EAGAIN and $! == &Errno::EAGAIN
!ll&&!rl&&r
000
exists &Errno::EAGAIN and $! == &Errno::EAGAIN
!ll&&!rl&&r
000
MC/DC0%0/2
exists &Errno::EAGAIN and $! == &Errno::EAGAIN
exists &Errno::EAGAIN $! == &Errno::EAGAIN
MC/DC0%0/2
exists &Errno::EAGAIN and $! == &Errno::EAGAIN
exists &Errno::EAGAIN $! == &Errno::EAGAIN
Truth table0%0/3
A and B
A= exists &Errno::EAGAINB= $! == &Errno::EAGAIN
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= exists &Errno::EAGAINB= $! == &Errno::EAGAIN
ABresult
0X0
100
111
27 0 ▶ $CPAN::Frontend->mydie("Could not open '$file' after 10000 tries: $!") if ++$cnt > 100000;
Branch: 2 branches
BranchTrueFalseTotal
if ++$cnt > 100000 0 0 0
if ++$cnt > 100000 0 0 0
28 0 sleep 0.0001;
29 0 mkpath $parent_dir;
30 }
31 }
32  
33 #-> sub CPAN::FTP::ftp_statistics
34 # if they want to rewrite, they need to pass in a filehandle
35 48 ▶sub _ftp_statistics {
Subroutine _ftp_statistics: called CC=15 SCAR=49.0
36 0 ▶ my($self,$fh) = @_;
Subroutine _ftp_statistics: not called CC=15 SCAR=49.0
37 0 my $ftpstats_size = $CPAN::Config->{ftpstats_size};
38 0 ▶ return if defined $ftpstats_size && $ftpstats_size <= 0;
Branch: 2 branches
BranchTrueFalseTotal
if defined $ftpstats_size and $ftpstats_size <= 0 0 48 48
if defined $ftpstats_size and $ftpstats_size <= 0 0 0 0
Condition16%1/6
defined $ftpstats_size and $ftpstats_size <= 0
!ll&&!rl&&r
4800
defined $ftpstats_size and $ftpstats_size <= 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ftpstats_size and $ftpstats_size <= 0
defined $ftpstats_size $ftpstats_size <= 0
MC/DC0%0/2
defined $ftpstats_size and $ftpstats_size <= 0
defined $ftpstats_size $ftpstats_size <= 0
Truth table33%1/3
A and B
A= defined $ftpstats_sizeB= $ftpstats_size <= 0
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $ftpstats_sizeB= $ftpstats_size <= 0
ABresult
0X0
100
111
39 0 ▶ my $locktype = $fh ? LOCK_EX : LOCK_SH;
Branch: 2 branches
BranchTrueFalseTotal
$fh ? : 41 7 48
$fh ? : 0 0 0
40 # XXX On Windows flock() implements mandatory locking, so we can
41 # XXX only use shared locking to still allow _yaml_loadfile() to
42 # XXX read from the file using a different filehandle.
43 0 ▶ $locktype = LOCK_SH if $^O eq "MSWin32";
Branch: 2 branches
BranchTrueFalseTotal
if $^O eq "MSWin32" 0 48 48
if $^O eq "MSWin32" 0 0 0
44  
45 0 ▶ $fh ||= FileHandle->new;
Condition33%2/6
$fh ||= "FileHandle"->new
l!l&&r!l&&!r
4170
$fh ||= "FileHandle"->new
l!l&&r!l&&!r
000
MC/DC0%0/2
$fh ||= "FileHandle"->new
$fh "FileHandle"->new
MC/DC0%0/2
$fh ||= "FileHandle"->new
$fh "FileHandle"->new
Truth table66%2/3
A ||= B
A= $fhB= "FileHandle"->new
ABresult
1X1
011
000
Truth table0%0/3
A ||= B
A= $fhB= "FileHandle"->new
ABresult
1X1
011
000
46 0 my $file = File::Spec->catfile($CPAN::Config->{cpan_home},"FTPstats.yml");
47 0 _plus_append_open($fh,$file);
48 0 my $sleep = 1;
49 0 my $waitstart;
50 0 ▶ while (!CPAN::_flock($fh, $locktype|LOCK_NB)) {
Branch: 2 branches
BranchTrueFalseTotal
unless (CPAN::_flock($fh, $locktype | 4)) 0 48 48
unless (CPAN::_flock($fh, $locktype | 4)) 0 0 0
51 0 ▶ $waitstart ||= localtime();
Condition0%0/6
$waitstart ||= localtime()
l!l&&r!l&&!r
000
$waitstart ||= localtime()
l!l&&r!l&&!r
000
MC/DC0%0/2
$waitstart ||= localtime()
$waitstart localtime()
MC/DC0%0/2
$waitstart ||= localtime()
$waitstart localtime()
Truth table0%0/3
A ||= B
A= $waitstartB= localtime()
ABresult
1X1
011
000
Truth table0%0/3
A ||= B
A= $waitstartB= localtime()
ABresult
1X1
011
000
52 0 ▶ if ($sleep>3) {
Branch: 2 branches
BranchTrueFalseTotal
if ($sleep > 3) 0 0 0
if ($sleep > 3) 0 0 0
53 0 my $now = localtime();
54 0 $CPAN::Frontend->mywarn("$now: waiting for read lock on '$file' (since $waitstart)\n");
55 }
56 0 sleep($sleep); # this sleep must not be overridden;
57 # Frontend->mysleep with AUTOMATED_TESTING has
58 # provoked complete lock contention on my NFS
59 0 ▶ if ($sleep <= 6) {
Branch: 2 branches
BranchTrueFalseTotal
if ($sleep <= 6) { } 0 0 0
if ($sleep <= 6) { } 0 0 0
60 0 $sleep+=0.5;
61 } else {
62 # retry to get a fresh handle. If it is NFS and the handle is stale, we will never get an flock
63 0 _plus_append_open($fh, $file);
64 }
65 }
66 0 my $stats = eval { CPAN->_yaml_loadfile($file, {loadblessed => 1}); };
67 0 ▶ if ($@) {
Branch: 2 branches
BranchTrueFalseTotal
if ($@) 0 48 48
if ($@) 0 0 0
68 0 ▶ if (ref $@) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $@) { } 0 0 0
if (ref $@) { } 0 0 0
69 0 ▶ if (ref $@ eq "CPAN::Exception::yaml_not_installed") {
Branch: 4 branches
BranchTrueFalseTotal
if (ref $@ eq 'CPAN::Exception::yaml_not_installed') { } 0 0 0
elsif (ref $@ eq 'CPAN::Exception::yaml_process_error') { } 0 0 0
if (ref $@ eq 'CPAN::Exception::yaml_not_installed') { } 0 0 0
elsif (ref $@ eq 'CPAN::Exception::yaml_process_error') { } 0 0 0
70 0 chomp $@;
71 0 $CPAN::Frontend->myprintonce("Warning (usually harmless): $@\n");
72 0 return;
73 } elsif (ref $@ eq "CPAN::Exception::yaml_process_error") {
74 0 my $time = time;
75 0 my $to = "$file.$time";
76 0 $CPAN::Frontend->mywarn("Error reading '$file': $@
77 Trying to stash it away as '$to' to prevent further interruptions.
78 You may want to remove that file later.\n");
79 # may fail because somebody else has moved it away in the meantime:
80 0 ▶ rename $file, $to or $CPAN::Frontend->mywarn("Could not rename '$file' to '$to': $!\n");
Branch: 2 branches
BranchTrueFalseTotal
rename $file, $to or $CPAN::Frontend->mywarn("Could not rename '${file}' to '${to}': $!\n") 0 0 0
rename $file, $to or $CPAN::Frontend->mywarn("Could not rename '${file}' to '${to}': $!\n") 0 0 0
81 0 return;
82 }
83 } else {
84 0 $CPAN::Frontend->mydie($@);
85 }
86 }
87 0 CPAN::_flock($fh, LOCK_UN);
88 0 return $stats->[0];
89 }
90  
91 #-> sub CPAN::FTP::_mytime
92 123 ▶sub _mytime () {
Subroutine _mytime: called CC=2 SCAR=12.2
93 0 ▶ if (CPAN->has_inst("Time::HiRes")) {
Subroutine _mytime: not called CC=2 SCAR=12.2
Branch: 2 branches
BranchTrueFalseTotal
if ('CPAN'->has_inst('Time::HiRes')) { } 123 0 123
if ('CPAN'->has_inst('Time::HiRes')) { } 0 0 0
94 0 return Time::HiRes::time();
95 } else {
96 0 return time;
97 }
98 }
99  
100 #-> sub CPAN::FTP::_new_stats
101 41 ▶sub _new_stats {
Subroutine _new_stats: called CC=1 SCAR=1.2
102 0 ▶ my($self,$file) = @_;
Subroutine _new_stats: not called CC=1 SCAR=1.2
103 0 my $ret = {
104 file => $file,
105 attempts => [],
106 start => _mytime,
107 };
108 0 $ret;
109 }
110  
111 #-> sub CPAN::FTP::_add_to_statistics
112 41 ▶sub _add_to_statistics {
Subroutine _add_to_statistics: called CC=23 SCAR=52.5
113 0 ▶ my($self,$stats) = @_;
Subroutine _add_to_statistics: not called CC=23 SCAR=52.5
114 0 my $yaml_module = CPAN::_yaml_module();
115 0 ▶ $self->debug("yaml_module[$yaml_module]") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 41 41
if $CPAN::DEBUG 0 0 0
116 0 ▶ if ($CPAN::META->has_inst($yaml_module)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::META->has_inst($yaml_module)) 41 0 41
if ($CPAN::META->has_inst($yaml_module)) 0 0 0
117 0 $stats->{thesiteurl} = $ThesiteURL;
118 0 $stats->{end} = CPAN::FTP::_mytime();
119 0 my $fh = FileHandle->new;
120 0 my $time = time;
121 0 my $sdebug = 0;
122 0 my @debug;
123 0 ▶ @debug = $time if $sdebug;
Branch: 2 branches
BranchTrueFalseTotal
if $sdebug 0 41 41
if $sdebug 0 0 0
124 0 my $fullstats = $self->_ftp_statistics($fh);
125 0 ▶ close $fh if $fh && defined(fileno($fh));
Branch: 2 branches
BranchTrueFalseTotal
if $fh and defined fileno $fh 41 0 41
if $fh and defined fileno $fh 0 0 0
Condition16%1/6
$fh and defined fileno $fh
!ll&&!rl&&r
0041
$fh and defined fileno $fh
!ll&&!rl&&r
000
MC/DC0%0/2
$fh and defined fileno $fh
$fh defined fileno $fh
MC/DC0%0/2
$fh and defined fileno $fh
$fh defined fileno $fh
Truth table33%1/3
A and B
A= $fhB= defined fileno $fh
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $fhB= defined fileno $fh
ABresult
0X0
100
111
126 0 ▶ $fullstats->{history} ||= [];
Condition50%2/4
$fullstats->{"history"} ||= []
l!l
383
$fullstats->{"history"} ||= []
l!l
00
MC/DC100%1/1
$fullstats->{"history"} ||= []
$fullstats->{"history"}
MC/DC0%0/1
$fullstats->{"history"} ||= []
$fullstats->{"history"}
Truth table100%2/2
A
A= $fullstats->{"history"}
Aresult
11
00
Truth table0%0/2
A
A= $fullstats->{"history"}
Aresult
11
00
127 0 ▶ push @debug, scalar @{$fullstats->{history}} if $sdebug;
Branch: 2 branches
BranchTrueFalseTotal
if $sdebug 0 41 41
if $sdebug 0 0 0
128 0 ▶ push @debug, time if $sdebug;
Branch: 2 branches
BranchTrueFalseTotal
if $sdebug 0 41 41
if $sdebug 0 0 0
129 0 push @{$fullstats->{history}}, $stats;
130 # YAML.pm 0.62 is unacceptably slow with 999;
131 # YAML::Syck 0.82 has no noticable performance problem with 999;
132 0 my $ftpstats_size = $CPAN::Config->{ftpstats_size};
133 0 ▶ $ftpstats_size = 99 unless defined $ftpstats_size;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $ftpstats_size 41 0 41
unless defined $ftpstats_size 0 0 0
134 0 ▶ my $ftpstats_period = $CPAN::Config->{ftpstats_period} || 14;
Condition25%1/4
$CPAN::Config->{'ftpstats_period'} || 14
l!l
041
$CPAN::Config->{'ftpstats_period'} || 14
l!l
00
MC/DC0%0/1
$CPAN::Config->{'ftpstats_period'} || 14
$CPAN::Config->{'ftpstats_period'}
MC/DC0%0/1
$CPAN::Config->{'ftpstats_period'} || 14
$CPAN::Config->{'ftpstats_period'}
Truth table50%1/2
A
A= $CPAN::Config->{'ftpstats_period'}
Aresult
11
00
Truth table0%0/2
A
A= $CPAN::Config->{'ftpstats_period'}
Aresult
11
00
135 0 ▶ while (
Branch: 2 branches
BranchTrueFalseTotal
if (@{$fullstats->{"history"} or [];} and @{$fullstats->{"history"};} > $ftpstats_size || $time - $fullstats->{"history"}[0]{"start"} > 86400 * $ftpstats_period) 0 41 41
if (@{$fullstats->{"history"} or [];} and @{$fullstats->{"history"};} > $ftpstats_size || $time - $fullstats->{"history"}[0]{"start"} > 86400 * $ftpstats_period) 0 0 0
Condition16%1/6
@{$fullstats->{"history"} or [];} and @{$fullstats->{"history"};} > $ftpstats_size || $time - $fullstats->{"history"}[0]{"start"} > 86400 * $ftpstats_period
!ll&&!rl&&r
0410
@{$fullstats->{"history"} or [];} and @{$fullstats->{"history"};} > $ftpstats_size || $time - $fullstats->{"history"}[0]{"start"} > 86400 * $ftpstats_period
!ll&&!rl&&r
000
MC/DC0%0/2
@{$fullstats->{"history"} or [];} and @{$fullstats->{"history"};} > $ftpstats_size || $time - $fullstats->{"history"}[0]{"start"} > 86400 * $ftpstats_period
@{$fullstats->{"history"} or [];} @{$fullstats->{"history"};} > $ftpstats_size || $time - $fullstats->{"history"}[0]{"start"} > 86400 * $ftpstats_period
MC/DC0%0/2
@{$fullstats->{"history"} or [];} and @{$fullstats->{"history"};} > $ftpstats_size || $time - $fullstats->{"history"}[0]{"start"} > 86400 * $ftpstats_period
@{$fullstats->{"history"} or [];} @{$fullstats->{"history"};} > $ftpstats_size || $time - $fullstats->{"history"}[0]{"start"} > 86400 * $ftpstats_period
Truth table33%1/3
A and B
A= @{$fullstats->{"history"} or [];}B= @{$fullstats->{"history"};} > $ftpstats_size || $time - $fullstats->{"history"}[0]{"start"} > 86400 * $ftpstats_period
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= @{$fullstats->{"history"} or [];}B= @{$fullstats->{"history"};} > $ftpstats_size || $time - $fullstats->{"history"}[0]{"start"} > 86400 * $ftpstats_period
ABresult
0X0
100
111
136 0 ▶ @{$fullstats->{history} || []}
Condition20%2/10
$fullstats->{'history'} || []
l!l
410
@{$fullstats->{"history"};} > $ftpstats_size or $time - $fullstats->{"history"}[0]{"start"} > 86400 * $ftpstats_period
l!l&&r!l&&!r
0041
$fullstats->{'history'} || []
l!l
00
@{$fullstats->{"history"};} > $ftpstats_size or $time - $fullstats->{"history"}[0]{"start"} > 86400 * $ftpstats_period
l!l&&r!l&&!r
000
MC/DC0%0/1
$fullstats->{'history'} || []
$fullstats->{'history'}
MC/DC0%0/2
@{$fullstats->{"history"};} > $ftpstats_size or $time - $fullstats->{"history"}[0]{"start"} > 86400 * $ftpstats_period
@{$fullstats->{"history"};} > $ftpstats_size $time - $fullstats->{"history"}[0]{"start"} > 86400 * $ftpstats_period
MC/DC0%0/1
$fullstats->{'history'} || []
$fullstats->{'history'}
MC/DC0%0/2
@{$fullstats->{"history"};} > $ftpstats_size or $time - $fullstats->{"history"}[0]{"start"} > 86400 * $ftpstats_period
@{$fullstats->{"history"};} > $ftpstats_size $time - $fullstats->{"history"}[0]{"start"} > 86400 * $ftpstats_period
Truth table50%1/2
A
A= $fullstats->{'history'}
Aresult
11
00
Truth table33%1/3
A or B
A= @{$fullstats->{"history"};} > $ftpstats_sizeB= $time - $fullstats->{"history"}[0]{"start"} > 86400 * $ftpstats_period
ABresult
1X1
011
000
Truth table0%0/2
A
A= $fullstats->{'history'}
Aresult
11
00
Truth table0%0/3
A or B
A= @{$fullstats->{"history"};} > $ftpstats_sizeB= $time - $fullstats->{"history"}[0]{"start"} > 86400 * $ftpstats_period
ABresult
1X1
011
000
137 &&
138 (
139 0 @{$fullstats->{history}} > $ftpstats_size
140 || $time - $fullstats->{history}[0]{start} > 86400*$ftpstats_period
141 )
142 ) {
143 0 shift @{$fullstats->{history}}
144 }
145 0 ▶ push @debug, scalar @{$fullstats->{history}} if $sdebug;
Branch: 2 branches
BranchTrueFalseTotal
if $sdebug 0 41 41
if $sdebug 0 0 0
146 0 ▶ push @debug, time if $sdebug;
Branch: 2 branches
BranchTrueFalseTotal
if $sdebug 0 41 41
if $sdebug 0 0 0
147 0 ▶ push @debug, scalar localtime($fullstats->{history}[0]{start}) if $sdebug;
Branch: 2 branches
BranchTrueFalseTotal
if $sdebug 0 41 41
if $sdebug 0 0 0
148 # need no eval because if this fails, it is serious
149 0 my $sfile = File::Spec->catfile($CPAN::Config->{cpan_home},"FTPstats.yml");
150 0 CPAN->_yaml_dumpfile("$sfile.$$",$fullstats);
151 0 ▶ if ( $sdebug ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($sdebug) 0 41 41
if ($sdebug) 0 0 0
152 0 local $CPAN::DEBUG = 512; # FTP
153 0 push @debug, time;
154 0 CPAN->debug(sprintf("DEBUG history: before_read[%d]before[%d]at[%d]".
155 "after[%d]at[%d]oldest[%s]dumped backat[%d]",
156 @debug,
157 ));
158 }
159 # Win32 cannot rename a file to an existing filename
160 0 ▶ unlink($sfile) if ($^O eq 'MSWin32' or $^O eq 'os2');
Branch: 2 branches
BranchTrueFalseTotal
if $^O eq "MSWin32" or $^O eq "os2" 0 41 41
if $^O eq "MSWin32" or $^O eq "os2" 0 0 0
Condition16%1/6
$^O eq "MSWin32" or $^O eq "os2"
l!l&&r!l&&!r
0041
$^O eq "MSWin32" or $^O eq "os2"
l!l&&r!l&&!r
000
MC/DC0%0/2
$^O eq "MSWin32" or $^O eq "os2"
$^O eq "MSWin32" $^O eq "os2"
MC/DC0%0/2
$^O eq "MSWin32" or $^O eq "os2"
$^O eq "MSWin32" $^O eq "os2"
Truth table33%1/3
A or B
A= $^O eq "MSWin32"B= $^O eq "os2"
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $^O eq "MSWin32"B= $^O eq "os2"
ABresult
1X1
011
000
161 0 ▶ _copy_stat($sfile, "$sfile.$$") if -e $sfile;
Branch: 2 branches
BranchTrueFalseTotal
if -e $sfile 41 0 41
if -e $sfile 0 0 0
162 0 ▶ rename "$sfile.$$", $sfile
Branch: 2 branches
BranchTrueFalseTotal
rename "$sfile.${$}", $sfile or $CPAN::Frontend->mywarn("Could not rename '$sfile.${$}' to '${sfile}': $!\nGiving up\n") 41 0 41
rename "$sfile.${$}", $sfile or $CPAN::Frontend->mywarn("Could not rename '$sfile.${$}' to '${sfile}': $!\nGiving up\n") 0 0 0
163 or $CPAN::Frontend->mywarn("Could not rename '$sfile.$$' to '$sfile': $!\nGiving up\n");
164 }
165 }
166  
167 # Copy some stat information (owner, group, mode and) from one file to
168 # another.
169 # This is a utility function which might be moved to a utility repository.
170 #-> sub CPAN::FTP::_copy_stat
171 41 ▶sub _copy_stat {
Subroutine _copy_stat: called CC=6 SCAR=29.0
172 0 ▶ my($src, $dest) = @_;
Subroutine _copy_stat: not called CC=6 SCAR=29.0
173 0 my @stat = stat($src);
174 0 ▶ if (!@stat) {
Branch: 2 branches
BranchTrueFalseTotal
unless (@stat) 0 41 41
unless (@stat) 0 0 0
175 0 $CPAN::Frontend->mywarn("Can't stat '$src': $!\n");
176 0 return;
177 }
178  
179 0 eval {
180 0 ▶ chmod $stat[2], $dest
Branch: 2 branches
BranchTrueFalseTotal
chmod $stat[2], $dest or $CPAN::Frontend->mywarn("Can't chmod '${dest}' to " . sprintf("0%o", $stat[2]) . ": $!\n") 41 0 41
chmod $stat[2], $dest or $CPAN::Frontend->mywarn("Can't chmod '${dest}' to " . sprintf("0%o", $stat[2]) . ": $!\n") 0 0 0
181 or $CPAN::Frontend->mywarn("Can't chmod '$dest' to " . sprintf("0%o", $stat[2]) . ": $!\n");
182 };
183 0 ▶ warn $@ if $@;
Branch: 2 branches
BranchTrueFalseTotal
if $@ 0 41 41
if $@ 0 0 0
184 0 eval {
185 chown $stat[4], $stat[5], $dest
186 0 ▶ or do {
Branch: 2 branches
BranchTrueFalseTotal
chown $stat[4], $stat[5], $dest or do { my $save_err = $!; $CPAN::Frontend->mywarn("Can't chown '${dest}' to " . (getpwuid $stat[4])[0] . '/' . (getgrgid $stat[5])[0] . ": $save_err\n") } 41 0 41
chown $stat[4], $stat[5], $dest or do { my $save_err = $!; $CPAN::Frontend->mywarn("Can't chown '${dest}' to " . (getpwuid $stat[4])[0] . '/' . (getgrgid $stat[5])[0] . ": $save_err\n") } 0 0 0
187 0 my $save_err = $!; # otherwise it's lost in the get... calls
188 0 $CPAN::Frontend->mywarn("Can't chown '$dest' to " .
189 (getpwuid($stat[4]))[0] . "/" .
190 (getgrgid($stat[5]))[0] . ": $save_err\n"
191 );
192 };
193 };
194 0 ▶ warn $@ if $@;
Branch: 2 branches
BranchTrueFalseTotal
if $@ 0 41 41
if $@ 0 0 0
195 }
196  
197 # if file is CHECKSUMS, suggest the place where we got the file to be
198 # checked from, maybe only for young files?
199 #-> sub CPAN::FTP::_recommend_url_for
200 41 ▶sub _recommend_url_for {
Subroutine _recommend_url_for: called CC=9 SCAR=34.6
201 0 ▶ my($self, $file, $urllist) = @_;
Subroutine _recommend_url_for: not called CC=9 SCAR=34.6
202 0 ▶ if ($file =~ s|/CHECKSUMS(.gz)?$||) {
Branch: 2 branches
BranchTrueFalseTotal
if ($file =~ s[/CHECKSUMS(.gz)?$][]) 7 34 41
if ($file =~ s[/CHECKSUMS(.gz)?$][]) 0 0 0
203 0 my $fullstats = $self->_ftp_statistics();
204 0 ▶ my $history = $fullstats->{history} || [];
Condition25%1/4
$fullstats->{'history'} || []
l!l
70
$fullstats->{'history'} || []
l!l
00
MC/DC0%0/1
$fullstats->{'history'} || []
$fullstats->{'history'}
MC/DC0%0/1
$fullstats->{'history'} || []
$fullstats->{'history'}
Truth table50%1/2
A
A= $fullstats->{'history'}
Aresult
11
00
Truth table0%0/2
A
A= $fullstats->{'history'}
Aresult
11
00
205 0 ▶ while (my $last = pop @$history) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $last = pop @$history) 7 0 7
if (my $last = pop @$history) 0 0 0
206 0 ▶ last if $last->{end} - time > 3600; # only young results are interesting
Branch: 2 branches
BranchTrueFalseTotal
if $last->{"end"} - time > 3600 0 7 7
if $last->{"end"} - time > 3600 0 0 0
207 0 ▶ next unless $last->{file}; # dirname of nothing dies!
Branch: 2 branches
BranchTrueFalseTotal
unless $last->{"file"} 0 7 7
unless $last->{"file"} 0 0 0
208 0 ▶ next unless $file eq dirname($last->{file});
Branch: 2 branches
BranchTrueFalseTotal
unless $file eq dirname($last->{"file"}) 0 7 7
unless $file eq dirname($last->{"file"}) 0 0 0
209 0 return $last->{thesiteurl};
210 }
211 }
212 0 ▶ if ($CPAN::Config->{randomize_urllist}
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::Config->{'randomize_urllist'} and rand 1 < $CPAN::Config->{'randomize_urllist'}) { } 0 34 34
if ($CPAN::Config->{'randomize_urllist'} and rand 1 < $CPAN::Config->{'randomize_urllist'}) { } 0 0 0
Condition16%1/6
$CPAN::Config->{"randomize_urllist"} and rand 1 < $CPAN::Config->{"randomize_urllist"}
!ll&&!rl&&r
3400
$CPAN::Config->{"randomize_urllist"} and rand 1 < $CPAN::Config->{"randomize_urllist"}
!ll&&!rl&&r
000
MC/DC0%0/2
$CPAN::Config->{"randomize_urllist"} and rand 1 < $CPAN::Config->{"randomize_urllist"}
$CPAN::Config->{"randomize_urllist"} rand 1 < $CPAN::Config->{"randomize_urllist"}
MC/DC0%0/2
$CPAN::Config->{"randomize_urllist"} and rand 1 < $CPAN::Config->{"randomize_urllist"}
$CPAN::Config->{"randomize_urllist"} rand 1 < $CPAN::Config->{"randomize_urllist"}
Truth table33%1/3
A and B
A= $CPAN::Config->{"randomize_urllist"}B= rand 1 < $CPAN::Config->{"randomize_urllist"}
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $CPAN::Config->{"randomize_urllist"}B= rand 1 < $CPAN::Config->{"randomize_urllist"}
ABresult
0X0
100
111
213 &&
214 rand(1) < $CPAN::Config->{randomize_urllist}
215 ) {
216 0 $urllist->[int rand scalar @$urllist];
217 } else {
218 0 return ();
219 }
220 }
221  
222 #-> sub CPAN::FTP::_get_urllist
223 41 ▶sub _get_urllist {
Subroutine _get_urllist: called CC=12 SCAR=40.9
224 0 ▶ my($self, $with_defaults) = @_;
Subroutine _get_urllist: not called CC=12 SCAR=40.9
225 0 ▶ $with_defaults ||= 0;
Condition25%1/4
$with_defaults ||= 0
l!l
041
$with_defaults ||= 0
l!l
00
MC/DC0%0/1
$with_defaults ||= 0
$with_defaults
MC/DC0%0/1
$with_defaults ||= 0
$with_defaults
Truth table50%1/2
A
A= $with_defaults
Aresult
11
00
Truth table0%0/2
A
A= $with_defaults
Aresult
11
00
226 0 ▶ CPAN->debug("with_defaults[$with_defaults]") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 41 41
if $CPAN::DEBUG 0 0 0
227  
228 0 ▶ $CPAN::Config->{urllist} ||= [];
Condition25%1/4
$CPAN::Config->{"urllist"} ||= []
l!l
410
$CPAN::Config->{"urllist"} ||= []
l!l
00
MC/DC0%0/1
$CPAN::Config->{"urllist"} ||= []
$CPAN::Config->{"urllist"}
MC/DC0%0/1
$CPAN::Config->{"urllist"} ||= []
$CPAN::Config->{"urllist"}
Truth table50%1/2
A
A= $CPAN::Config->{"urllist"}
Aresult
11
00
Truth table0%0/2
A
A= $CPAN::Config->{"urllist"}
Aresult
11
00
229 0 ▶ unless (ref $CPAN::Config->{urllist} eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
unless (ref $CPAN::Config->{"urllist"} eq "ARRAY") 0 41 41
unless (ref $CPAN::Config->{"urllist"} eq "ARRAY") 0 0 0
230 0 $CPAN::Frontend->mywarn("Malformed urllist; ignoring. Configuration file corrupt?\n");
231 0 $CPAN::Config->{urllist} = [];
232 }
233 0 ▶ my @urllist = grep { defined $_ and length $_ } @{$CPAN::Config->{urllist}};
Condition16%1/6
defined $_ && length $_
!ll&&!rl&&r
0041
defined $_ && length $_
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_ && length $_
defined $_ length $_
MC/DC0%0/2
defined $_ && length $_
defined $_ length $_
Truth table33%1/3
A && B
A= defined $_B= length $_
ABresult
0X0
100
111
Truth table0%0/3
A && B
A= defined $_B= length $_
ABresult
0X0
100
111
234 0 ▶ push @urllist, @CPAN::Defaultsites if $with_defaults;
Branch: 2 branches
BranchTrueFalseTotal
if $with_defaults 0 41 41
if $with_defaults 0 0 0
235 0 for my $u (@urllist) {
236 0 ▶ CPAN->debug("u[$u]") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 41 41
if $CPAN::DEBUG 0 0 0
237 0 ▶ if (UNIVERSAL::can($u,"text")) {
Branch: 2 branches
BranchTrueFalseTotal
if (UNIVERSAL::can($u, 'text')) { } 0 41 41
if (UNIVERSAL::can($u, 'text')) { } 0 0 0
238 0 ▶ $u->{TEXT} .= "/" unless substr($u->{TEXT},-1) eq "/";
Branch: 2 branches
BranchTrueFalseTotal
unless substr($u->{"TEXT"}, -1) eq "/" 0 0 0
unless substr($u->{"TEXT"}, -1) eq "/" 0 0 0
239 } else {
240 0 ▶ $u .= "/" unless substr($u,-1) eq "/";
Branch: 2 branches
BranchTrueFalseTotal
unless substr($u, -1) eq "/" 41 0 41
unless substr($u, -1) eq "/" 0 0 0
241 0 $u = CPAN::URL->new(TEXT => $u, FROM => "USER");
242 }
243 }
244 0 \@urllist;
245 }
246  
247 #-> sub CPAN::FTP::ftp_get ;
248 0 ▶sub ftp_get {
Subroutine ftp_get: not called CC=9 SCAR=45.0
Pod undocumented
249 0 ▶ my($class,$host,$dir,$file,$target) = @_;
Subroutine ftp_get: not called CC=9 SCAR=45.0
Pod undocumented
250 0 ▶ $class->debug(
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
251 qq[Going to fetch file [$file] from dir [$dir]
252 on host [$host] as local [$target]\n]
253 ) if $CPAN::DEBUG;
254 0 my $ftp = Net::FTP->new($host);
255 0 ▶ unless ($ftp) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($ftp) 0 0 0
unless ($ftp) 0 0 0
256 0 $CPAN::Frontend->mywarn(" Could not connect to host '$host' with Net::FTP\n");
257 0 return;
258 }
259 0 ▶ return 0 unless defined $ftp;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $ftp 0 0 0
unless defined $ftp 0 0 0
260 0 ▶ $ftp->debug(1) if $CPAN::DEBUG{'FTP'} & $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG{"FTP"} & $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG{"FTP"} & $CPAN::DEBUG 0 0 0
261 0 $class->debug(qq[Going to login("anonymous","$Config::Config{cf_email}")]);
262 0 ▶ unless ( $ftp->login("anonymous",$Config::Config{'cf_email'}) ) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($ftp->login("anonymous", $Config::Config{"cf_email"})) 0 0 0
unless ($ftp->login("anonymous", $Config::Config{"cf_email"})) 0 0 0
263 0 my $msg = $ftp->message;
264 0 $CPAN::Frontend->mywarn(" Couldn't login on $host: $msg\n");
265 0 return;
266 }
267 0 ▶ unless ( $ftp->cwd($dir) ) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($ftp->cwd($dir)) 0 0 0
unless ($ftp->cwd($dir)) 0 0 0
268 0 my $msg = $ftp->message;
269 0 $CPAN::Frontend->mywarn(" Couldn't cwd $dir: $msg\n");
270 0 return;
271 }
272 0 $ftp->binary;
273 0 ▶ $class->debug(qq[Going to ->get("$file","$target")\n]) if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
274 0 ▶ unless ( $ftp->get($file,$target) ) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($ftp->get($file, $target)) 0 0 0
unless ($ftp->get($file, $target)) 0 0 0
275 0 my $msg = $ftp->message;
276 0 $CPAN::Frontend->mywarn(" Couldn't fetch $file from $host: $msg\n");
277 0 return;
278 }
279 0 $ftp->quit; # it's ok if this fails
280 0 return 1;
281 }
282  
283 # If more accuracy is wanted/needed, Chris Leach sent me this patch...
284  
285 # > *** /install/perl/live/lib/CPAN.pm- Wed Sep 24 13:08:48 1997
286 # > --- /tmp/cp Wed Sep 24 13:26:40 1997
287 # > ***************
288 # > *** 1562,1567 ****
289 # > --- 1562,1580 ----
290 # > return 1 if substr($url,0,4) eq "file";
291 # > return 1 unless $url =~ m|://([^/]+)|;
292 # > my $host = $1;
293 # > + my $proxy = $CPAN::Config->{'http_proxy'} || $ENV{'http_proxy'};
294 # > + if ($proxy) {
295 # > + $proxy =~ m|://([^/:]+)|;
296 # > + $proxy = $1;
297 # > + my $noproxy = $CPAN::Config->{'no_proxy'} || $ENV{'no_proxy'};
298 # > + if ($noproxy) {
299 # > + if ($host !~ /$noproxy$/) {
300 # > + $host = $proxy;
301 # > + }
302 # > + } else {
303 # > + $host = $proxy;
304 # > + }
305 # > + }
306 # > require Net::Ping;
307 # > return 1 unless $Net::Ping::VERSION >= 2;
308 # > my $p;
309  
310  
311 #-> sub CPAN::FTP::localize ;
312 41 ▶sub localize {
Subroutine localize: called CC=9 SCAR=34.6
Pod undocumented
313 0 ▶ my($self,$file,$aslocal,$force,$with_defaults) = @_;
Subroutine localize: not called CC=9 SCAR=34.6
Pod undocumented
314 0 ▶ $force ||= 0;
Condition50%2/4
$force ||= 0
l!l
347
$force ||= 0
l!l
00
MC/DC100%1/1
$force ||= 0
$force
MC/DC0%0/1
$force ||= 0
$force
Truth table100%2/2
A
A= $force
Aresult
11
00
Truth table0%0/2
A
A= $force
Aresult
11
00
315 0 ▶ Carp::croak( "Usage: ->localize(cpan_file,as_local_file[,\$force])" )
Branch: 2 branches
BranchTrueFalseTotal
unless defined $aslocal 0 41 41
unless defined $aslocal 0 0 0
316 unless defined $aslocal;
317 0 ▶ if ($CPAN::DEBUG){
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::DEBUG) 0 41 41
if ($CPAN::DEBUG) 0 0 0
318 0 require Carp;
319 0 my $longmess = Carp::longmess();
320 0 $self->debug("file[$file] aslocal[$aslocal] force[$force] carplongmess[$longmess]");
321 }
322 0 for ($CPAN::Config->{connect_to_internet_ok}) {
323 0 ▶ $connect_to_internet_ok = $_ if not defined $connect_to_internet_ok and defined $_;
Branch: 2 branches
BranchTrueFalseTotal
if not defined $CPAN::FTP::connect_to_internet_ok and defined $_ 7 34 41
if not defined $CPAN::FTP::connect_to_internet_ok and defined $_ 0 0 0
Condition50%3/6
not defined $CPAN::FTP::connect_to_internet_ok and defined $_
!ll&&!rl&&r
2867
not defined $CPAN::FTP::connect_to_internet_ok and defined $_
!ll&&!rl&&r
000
MC/DC100%2/2
not defined $CPAN::FTP::connect_to_internet_ok and defined $_
not defined $CPAN::FTP::connect_to_internet_ok defined $_
MC/DC0%0/2
not defined $CPAN::FTP::connect_to_internet_ok and defined $_
not defined $CPAN::FTP::connect_to_internet_ok defined $_
Truth table100%3/3
not(A) and B
A= not defined $CPAN::FTP::connect_to_internet_okB= defined $_
ABresult
0X0
100
111
Truth table0%0/3
not(A) and B
A= not defined $CPAN::FTP::connect_to_internet_okB= defined $_
ABresult
0X0
100
111
324 }
325 0 my $ph = $CPAN::Config->{pushy_https};
326 0 ▶ if (!defined $ph || $ph) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $ph or $ph) { } 0 41 41
if (not defined $ph or $ph) { } 0 0 0
Condition16%1/6
not defined $ph or $ph
l!l&&r!l&&!r
0041
not defined $ph or $ph
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $ph or $ph
not defined $ph $ph
MC/DC0%0/2
not defined $ph or $ph
not defined $ph $ph
Truth table33%1/3
not(A) or B
A= not defined $phB= $ph
ABresult
1X1
011
000
Truth table0%0/3
not(A) or B
A= not defined $phB= $ph
ABresult
1X1
011
000
327 0 return $self->localize_2021($file,$aslocal,$force,$with_defaults);
328 } else {
329 0 return $self->localize_1995ff($file,$aslocal,$force,$with_defaults);
330 }
331 }
332  
333 41 ▶sub have_promising_aslocal {
Subroutine have_promising_aslocal: called CC=7 SCAR=36.5
Pod undocumented
334 0 ▶ my($self, $aslocal, $force) = @_;
Subroutine have_promising_aslocal: not called CC=7 SCAR=36.5
Pod undocumented
335 0 ▶ if (-f $aslocal && -r _ && !($force & 1)) {
Branch: 2 branches
BranchTrueFalseTotal
if (-f $aslocal and -r _ and not $force & 1) 0 41 41
if (-f $aslocal and -r _ and not $force & 1) 0 0 0
Condition16%2/12
-f $aslocal and -r _ and not $force & 1
!ll&&!rl&&r
4100
-f $aslocal and -r _
!ll&&!rl&&r
4100
-f $aslocal and -r _ and not $force & 1
!ll&&!rl&&r
000
-f $aslocal and -r _
!ll&&!rl&&r
000
MC/DC0%0/3
-f $aslocal and -r _ and not $force & 1
-f $aslocal -r _ not $force & 1
MC/DC0%0/3
-f $aslocal and -r _ and not $force & 1
-f $aslocal -r _ not $force & 1
Truth table25%1/4
A and B and not(C)
A= -f $aslocalB= -r _C= not $force & 1
ABCresult
0XX0
10X0
1100
1111
Truth table0%0/4
A and B and not(C)
A= -f $aslocalB= -r _C= not $force & 1
ABCresult
0XX0
10X0
1100
1111
336 0 my $size;
337 0 ▶ if ($size = -s $aslocal) {
Branch: 2 branches
BranchTrueFalseTotal
if ($size = -s $aslocal) { } 0 0 0
if ($size = -s $aslocal) { } 0 0 0
338 0 ▶ $self->debug("aslocal[$aslocal]size[$size]") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
339 0 return 1;
340 } else {
341 # empty file from a previous unsuccessful attempt to download it
342 0 ▶ unlink $aslocal or
Branch: 2 branches
BranchTrueFalseTotal
unlink $aslocal or $CPAN::Frontend->mydie("Found a zero-length '${aslocal}' that I " . 'could not remove.') 0 0 0
unlink $aslocal or $CPAN::Frontend->mydie("Found a zero-length '${aslocal}' that I " . 'could not remove.') 0 0 0
343 $CPAN::Frontend->mydie("Found a zero-length '$aslocal' that I ".
344 "could not remove.");
345 }
346 }
347 0 return;
348 }
349  
350 #-> sub CPAN::FTP::localize ;
351 0 ▶sub localize_2021 {
Subroutine localize_2021: not called CC=17 SCAR=57.2
Pod undocumented
352 0 ▶ my($self,$file,$aslocal,$force,$with_defaults) = @_;
Subroutine localize_2021: not called CC=17 SCAR=57.2
Pod undocumented
353 0 ▶ return $aslocal if $self->have_promising_aslocal($aslocal, $force);
Branch: 2 branches
BranchTrueFalseTotal
if $self->have_promising_aslocal($aslocal, $force) 0 0 0
if $self->have_promising_aslocal($aslocal, $force) 0 0 0
354 0 my($aslocal_dir) = dirname($aslocal);
355 0 my $ret;
356 0 $self->mymkpath($aslocal_dir);
357 0 my $aslocal_tempfile = $aslocal . ".tmp" . $$;
358 0 my $base;
359 0 ▶ if (
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::META->has_usable('HTTP::Tiny') and $CPAN::META->has_usable('Net::SSLeay') and $CPAN::META->has_usable('IO::Socket::SSL') or $CPAN::Config->{'curl'} or $CPAN::Config->{'wget'}) { } 0 0 0
if ($CPAN::META->has_usable('HTTP::Tiny') and $CPAN::META->has_usable('Net::SSLeay') and $CPAN::META->has_usable('IO::Socket::SSL') or $CPAN::Config->{'curl'} or $CPAN::Config->{'wget'}) { } 0 0 0
Condition0%0/24
$CPAN::META->has_usable("HTTP::Tiny") and $CPAN::META->has_usable("Net::SSLeay") and $CPAN::META->has_usable("IO::Socket::SSL") or $CPAN::Config->{"curl"} or $CPAN::Config->{"wget"}
l!l&&r!l&&!r
000
$CPAN::META->has_usable("HTTP::Tiny") and $CPAN::META->has_usable("Net::SSLeay") and $CPAN::META->has_usable("IO::Socket::SSL") or $CPAN::Config->{"curl"}
l!l&&r!l&&!r
000
$CPAN::META->has_usable("HTTP::Tiny") and $CPAN::META->has_usable("Net::SSLeay") and $CPAN::META->has_usable("IO::Socket::SSL")
!ll&&!rl&&r
000
$CPAN::META->has_usable("HTTP::Tiny") and $CPAN::META->has_usable("Net::SSLeay")
!ll&&!rl&&r
000
$CPAN::META->has_usable("HTTP::Tiny") and $CPAN::META->has_usable("Net::SSLeay") and $CPAN::META->has_usable("IO::Socket::SSL") or $CPAN::Config->{"curl"} or $CPAN::Config->{"wget"}
l!l&&r!l&&!r
000
$CPAN::META->has_usable("HTTP::Tiny") and $CPAN::META->has_usable("Net::SSLeay") and $CPAN::META->has_usable("IO::Socket::SSL") or $CPAN::Config->{"curl"}
l!l&&r!l&&!r
000
$CPAN::META->has_usable("HTTP::Tiny") and $CPAN::META->has_usable("Net::SSLeay") and $CPAN::META->has_usable("IO::Socket::SSL")
!ll&&!rl&&r
000
$CPAN::META->has_usable("HTTP::Tiny") and $CPAN::META->has_usable("Net::SSLeay")
!ll&&!rl&&r
000
MC/DC0%0/5
$CPAN::META->has_usable("HTTP::Tiny") and $CPAN::META->has_usable("Net::SSLeay") and $CPAN::META->has_usable("IO::Socket::SSL") or $CPAN::Config->{"curl"} or $CPAN::Config->{"wget"}
$CPAN::META->has_usable("HTTP::Tiny") $CPAN::META->has_usable("Net::SSLeay") $CPAN::META->has_usable("IO::Socket::SSL") $CPAN::Config->{"curl"} $CPAN::Config->{"wget"}
MC/DC0%0/5
$CPAN::META->has_usable("HTTP::Tiny") and $CPAN::META->has_usable("Net::SSLeay") and $CPAN::META->has_usable("IO::Socket::SSL") or $CPAN::Config->{"curl"} or $CPAN::Config->{"wget"}
$CPAN::META->has_usable("HTTP::Tiny") $CPAN::META->has_usable("Net::SSLeay") $CPAN::META->has_usable("IO::Socket::SSL") $CPAN::Config->{"curl"} $CPAN::Config->{"wget"}
Truth table0%0/10
A and B and C or D or E
A= $CPAN::META->has_usable("HTTP::Tiny")B= $CPAN::META->has_usable("Net::SSLeay")C= $CPAN::META->has_usable("IO::Socket::SSL")D= $CPAN::Config->{"curl"}E= $CPAN::Config->{"wget"}
ABCDEresult
111XX1
0XX1X1
10X1X1
1101X1
0XX011
10X011
110011
0XX000
10X000
110000
Truth table0%0/10
A and B and C or D or E
A= $CPAN::META->has_usable("HTTP::Tiny")B= $CPAN::META->has_usable("Net::SSLeay")C= $CPAN::META->has_usable("IO::Socket::SSL")D= $CPAN::Config->{"curl"}E= $CPAN::Config->{"wget"}
ABCDEresult
111XX1
0XX1X1
10X1X1
1101X1
0XX011
10X011
110011
0XX000
10X000
110000
360 ($CPAN::META->has_usable('HTTP::Tiny')
361 && $CPAN::META->has_usable('Net::SSLeay')
362 && $CPAN::META->has_usable('IO::Socket::SSL')
363 )
364 || $CPAN::Config->{curl}
365 || $CPAN::Config->{wget}
366 ) {
367 0 for my $prx (qw(https_proxy no_proxy)) {
368 0 ▶ $ENV{$prx} = $CPAN::Config->{$prx} if $CPAN::Config->{$prx};
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::Config->{$prx} 0 0 0
if $CPAN::Config->{$prx} 0 0 0
369 }
370 0 $base = "https://www.cpan.org/";
371 } else {
372 0 my @missing_modules = grep { ! $CPAN::META->has_usable($_) } qw(HTTP::Tiny Net::SSLeay IO::Socket::SSL);
373 0 my $miss = join ", ", map { "'$_'" } @missing_modules;
374 0 ▶ my $modules = @missing_modules == 1 ? "module" : "modules";
Branch: 2 branches
BranchTrueFalseTotal
@missing_modules == 1 ? : 0 0 0
@missing_modules == 1 ? : 0 0 0
375 0 $CPAN::Frontend->mywarn("Missing or unusable $modules $miss, and found neither curl nor wget installed.\n");
376 0 ▶ if ($CPAN::META->has_usable('HTTP::Tiny')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::META->has_usable("HTTP::Tiny")) 0 0 0
if ($CPAN::META->has_usable("HTTP::Tiny")) 0 0 0
377 0 $CPAN::Frontend->mywarn("Need to fall back to http.\n")
378 }
379 0 for my $prx (qw(http_proxy no_proxy)) {
380 0 ▶ $ENV{$prx} = $CPAN::Config->{$prx} if $CPAN::Config->{$prx};
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::Config->{$prx} 0 0 0
if $CPAN::Config->{$prx} 0 0 0
381 }
382 0 $base = "http://www.cpan.org/";
383 }
384 0 $ret = $self->hostdl_2021($base,$file,$aslocal_tempfile);
385 0 ▶ if ($ret) { # c&p from below
Branch: 2 branches
BranchTrueFalseTotal
if ($ret) { } 0 0 0
if ($ret) { } 0 0 0
386 0 ▶ CPAN->debug("ret[$ret]aslocal[$aslocal]") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
387 0 ▶ if ($ret eq $aslocal_tempfile) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ret eq $aslocal_tempfile) 0 0 0
if ($ret eq $aslocal_tempfile) 0 0 0
388 # if we got it exactly as we asked for, only then we
389 # want to rename
390 0 ▶ rename $aslocal_tempfile, $aslocal
Branch: 2 branches
BranchTrueFalseTotal
rename $aslocal_tempfile, $aslocal or $CPAN::Frontend->mydie('Error while trying to rename ' . "'${ret}' to '${aslocal}': $!") 0 0 0
rename $aslocal_tempfile, $aslocal or $CPAN::Frontend->mydie('Error while trying to rename ' . "'${ret}' to '${aslocal}': $!") 0 0 0
391 or $CPAN::Frontend->mydie("Error while trying to rename ".
392 "'$ret' to '$aslocal': $!");
393 0 $ret = $aslocal;
394 }
395 } else {
396 0 unlink $aslocal_tempfile;
397 0 return;
398 }
399 0 return $ret;
400 }
401  
402 0 ▶sub hostdl_2021 {
Subroutine hostdl_2021: not called CC=28 SCAR=67.0
Pod undocumented
403 0 ▶ my($self, $base, $file, $aslocal) = @_; # the $aslocal is $aslocal_tempfile in the caller (old convention)
Subroutine hostdl_2021: not called CC=28 SCAR=67.0
Pod undocumented
404 0 my $proxy_vars = $self->_proxy_vars($base);
405 0 my($proto) = $base =~ /^(https?)/;
406 0 my $url = "$base$file";
407 # hostdl_2021 may be called with either http or https urls
408 0 ▶ if (
Branch: 4 branches
BranchTrueFalseTotal
if ($CPAN::META->has_usable('HTTP::Tiny') and $proto eq 'http' || $CPAN::META->has_usable('Net::SSLeay') && $CPAN::META->has_usable('IO::Socket::SSL')) { } 0 0 0
elsif ($CPAN::Config->{'curl'} or $CPAN::Config->{'wget'}) { } 0 0 0
if ($CPAN::META->has_usable('HTTP::Tiny') and $proto eq 'http' || $CPAN::META->has_usable('Net::SSLeay') && $CPAN::META->has_usable('IO::Socket::SSL')) { } 0 0 0
elsif ($CPAN::Config->{'curl'} or $CPAN::Config->{'wget'}) { } 0 0 0
Condition0%0/18
$CPAN::META->has_usable("HTTP::Tiny") and $proto eq "http" || $CPAN::META->has_usable("Net::SSLeay") && $CPAN::META->has_usable("IO::Socket::SSL")
!ll&&!rl&&r
000
$proto eq "http" or $CPAN::META->has_usable("Net::SSLeay") and $CPAN::META->has_usable("IO::Socket::SSL")
l!l&&r!l&&!r
000
$CPAN::META->has_usable("Net::SSLeay") and $CPAN::META->has_usable("IO::Socket::SSL")
!ll&&!rl&&r
000
$CPAN::META->has_usable("HTTP::Tiny") and $proto eq "http" || $CPAN::META->has_usable("Net::SSLeay") && $CPAN::META->has_usable("IO::Socket::SSL")
!ll&&!rl&&r
000
$proto eq "http" or $CPAN::META->has_usable("Net::SSLeay") and $CPAN::META->has_usable("IO::Socket::SSL")
l!l&&r!l&&!r
000
$CPAN::META->has_usable("Net::SSLeay") and $CPAN::META->has_usable("IO::Socket::SSL")
!ll&&!rl&&r
000
MC/DC0%0/4
$CPAN::META->has_usable("HTTP::Tiny") and $proto eq "http" || $CPAN::META->has_usable("Net::SSLeay") && $CPAN::META->has_usable("IO::Socket::SSL")
$CPAN::META->has_usable("HTTP::Tiny") $proto eq "http" $CPAN::META->has_usable("Net::SSLeay") $CPAN::META->has_usable("IO::Socket::SSL")
MC/DC0%0/4
$CPAN::META->has_usable("HTTP::Tiny") and $proto eq "http" || $CPAN::META->has_usable("Net::SSLeay") && $CPAN::META->has_usable("IO::Socket::SSL")
$CPAN::META->has_usable("HTTP::Tiny") $proto eq "http" $CPAN::META->has_usable("Net::SSLeay") $CPAN::META->has_usable("IO::Socket::SSL")
Truth table0%0/5
A and B or C and D
A= $CPAN::META->has_usable("HTTP::Tiny")B= $proto eq "http"C= $CPAN::META->has_usable("Net::SSLeay")D= $CPAN::META->has_usable("IO::Socket::SSL")
ABCDresult
0XXX0
100X0
10100
11XX1
10111
Truth table0%0/5
A and B or C and D
A= $CPAN::META->has_usable("HTTP::Tiny")B= $proto eq "http"C= $CPAN::META->has_usable("Net::SSLeay")D= $CPAN::META->has_usable("IO::Socket::SSL")
ABCDresult
0XXX0
100X0
10100
11XX1
10111
409 $CPAN::META->has_usable('HTTP::Tiny')
410 &&
411 (
412 $proto eq "http"
413 ||
414 ( $CPAN::META->has_usable('Net::SSLeay')
415 && $CPAN::META->has_usable('IO::Socket::SSL') )
416 )
417 ){
418 # mostly c&p from below
419 0 require CPAN::HTTP::Client;
420 my $chc = CPAN::HTTP::Client->new(
421 proxy => $CPAN::Config->{http_proxy} || $ENV{http_proxy},
422 no_proxy => $CPAN::Config->{no_proxy} || $ENV{no_proxy},
423 0 ▶ );
Condition0%0/12
$CPAN::Config->{'http_proxy'} || $ENV{'http_proxy'}
l!l&&r!l&&!r
000
$CPAN::Config->{'no_proxy'} || $ENV{'no_proxy'}
l!l&&r!l&&!r
000
$CPAN::Config->{'http_proxy'} || $ENV{'http_proxy'}
l!l&&r!l&&!r
000
$CPAN::Config->{'no_proxy'} || $ENV{'no_proxy'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$CPAN::Config->{'http_proxy'} || $ENV{'http_proxy'}
$CPAN::Config->{'http_proxy'} $ENV{'http_proxy'}
MC/DC0%0/2
$CPAN::Config->{'no_proxy'} || $ENV{'no_proxy'}
$CPAN::Config->{'no_proxy'} $ENV{'no_proxy'}
MC/DC0%0/2
$CPAN::Config->{'http_proxy'} || $ENV{'http_proxy'}
$CPAN::Config->{'http_proxy'} $ENV{'http_proxy'}
MC/DC0%0/2
$CPAN::Config->{'no_proxy'} || $ENV{'no_proxy'}
$CPAN::Config->{'no_proxy'} $ENV{'no_proxy'}
Truth table0%0/3
A || B
A= $CPAN::Config->{'http_proxy'}B= $ENV{'http_proxy'}
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $CPAN::Config->{'no_proxy'}B= $ENV{'no_proxy'}
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $CPAN::Config->{'http_proxy'}B= $ENV{'http_proxy'}
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $CPAN::Config->{'no_proxy'}B= $ENV{'no_proxy'}
ABresult
1X1
011
000
424 0 ▶ for my $try ( $url, ( $url !~ /\.gz(?!\n)\Z/ ? "$url.gz" : () ) ) {
Branch: 2 branches
BranchTrueFalseTotal
!($url =~ /\.gz(?!\n)\Z/) ? : 0 0 0
!($url =~ /\.gz(?!\n)\Z/) ? : 0 0 0
425 0 $CPAN::Frontend->myprint("Fetching with HTTP::Tiny:\n$try\n");
426 0 my $res = eval { $chc->mirror($try, $aslocal) };
427 0 ▶ if ( $res && $res->{success} ) {
Branch: 6 branches
BranchTrueFalseTotal
if ($res and $res->{'success'}) { } 0 0 0
elsif ($res and $res->{'status'} ne '599') { } 0 0 0
elsif ($res and $res->{'status'} eq '599') { } 0 0 0
if ($res and $res->{'success'}) { } 0 0 0
elsif ($res and $res->{'status'} ne '599') { } 0 0 0
elsif ($res and $res->{'status'} eq '599') { } 0 0 0
Condition0%0/6
$res and $res->{"success"}
!ll&&!rl&&r
000
$res and $res->{"success"}
!ll&&!rl&&r
000
MC/DC0%0/2
$res and $res->{"success"}
$res $res->{"success"}
MC/DC0%0/2
$res and $res->{"success"}
$res $res->{"success"}
Truth table0%0/3
A and B
A= $resB= $res->{"success"}
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $resB= $res->{"success"}
ABresult
0X0
100
111
428 0 my $now = time;
429 0 utime $now, $now, $aslocal; # download time is more
430 # important than upload
431 # time
432 0 return $aslocal;
433 }
434 ▶ elsif ( $res && $res->{status} ne '599') {
Condition0%0/6
$res and $res->{"status"} ne 599
!ll&&!rl&&r
000
$res and $res->{"status"} ne 599
!ll&&!rl&&r
000
MC/DC0%0/2
$res and $res->{"status"} ne 599
$res $res->{"status"} ne 599
MC/DC0%0/2
$res and $res->{"status"} ne 599
$res $res->{"status"} ne 599
Truth table0%0/3
A and B
A= $resB= $res->{"status"} ne 599
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $resB= $res->{"status"} ne 599
ABresult
0X0
100
111
435 $CPAN::Frontend->myprint(sprintf(
436 "HTTP::Tiny failed with code[%s] message[%s]\n",
437 $res->{status},
438 $res->{reason},
439 )
440 0 );
441 }
442 ▶ elsif ( $res && $res->{status} eq '599') {
Condition0%0/6
$res and $res->{"status"} eq 599
!ll&&!rl&&r
000
$res and $res->{"status"} eq 599
!ll&&!rl&&r
000
MC/DC0%0/2
$res and $res->{"status"} eq 599
$res $res->{"status"} eq 599
MC/DC0%0/2
$res and $res->{"status"} eq 599
$res $res->{"status"} eq 599
Truth table0%0/3
A and B
A= $resB= $res->{"status"} eq 599
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $resB= $res->{"status"} eq 599
ABresult
0X0
100
111
443 $CPAN::Frontend->myprint(sprintf(
444 "HTTP::Tiny failed with an internal error: %s\n",
445 $res->{content},
446 )
447 0 );
448 }
449 else {
450 0 ▶ my $err = $@ || 'Unknown error';
Condition0%0/4
$@ || 'Unknown error'
l!l
00
$@ || 'Unknown error'
l!l
00
MC/DC0%0/1
$@ || 'Unknown error'
$@
MC/DC0%0/1
$@ || 'Unknown error'
$@
Truth table0%0/2
A
A= $@
Aresult
11
00
Truth table0%0/2
A
A= $@
Aresult
11
00
451 0 $CPAN::Frontend->myprint(sprintf(
452 "Error downloading with HTTP::Tiny: %s\n", $err
453 )
454 );
455 }
456 }
457 ▶ } elsif ($CPAN::Config->{curl} || $CPAN::Config->{wget}){
Condition0%0/6
$CPAN::Config->{"curl"} or $CPAN::Config->{"wget"}
l!l&&r!l&&!r
000
$CPAN::Config->{"curl"} or $CPAN::Config->{"wget"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$CPAN::Config->{"curl"} or $CPAN::Config->{"wget"}
$CPAN::Config->{"curl"} $CPAN::Config->{"wget"}
MC/DC0%0/2
$CPAN::Config->{"curl"} or $CPAN::Config->{"wget"}
$CPAN::Config->{"curl"} $CPAN::Config->{"wget"}
Truth table0%0/3
A or B
A= $CPAN::Config->{"curl"}B= $CPAN::Config->{"wget"}
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $CPAN::Config->{"curl"}B= $CPAN::Config->{"wget"}
ABresult
1X1
011
000
458 # c&p from further down
459 0 my($src_switch, $stdout_redir);
460 0 ▶ my($devnull) = $CPAN::Config->{devnull} || "";
Condition0%0/4
$CPAN::Config->{'devnull'} || ''
l!l
00
$CPAN::Config->{'devnull'} || ''
l!l
00
MC/DC0%0/1
$CPAN::Config->{'devnull'} || ''
$CPAN::Config->{'devnull'}
MC/DC0%0/1
$CPAN::Config->{'devnull'} || ''
$CPAN::Config->{'devnull'}
Truth table0%0/2
A
A= $CPAN::Config->{'devnull'}
Aresult
11
00
Truth table0%0/2
A
A= $CPAN::Config->{'devnull'}
Aresult
11
00
461 0 DLPRG: for my $dlprg (qw(curl wget)) {
462 0 my $dlprg_configured = $CPAN::Config->{$dlprg};
463 0 ▶ next unless defined $dlprg_configured && length $dlprg_configured;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $dlprg_configured and length $dlprg_configured 0 0 0
unless defined $dlprg_configured and length $dlprg_configured 0 0 0
Condition0%0/6
defined $dlprg_configured and length $dlprg_configured
!ll&&!rl&&r
000
defined $dlprg_configured and length $dlprg_configured
!ll&&!rl&&r
000
MC/DC0%0/2
defined $dlprg_configured and length $dlprg_configured
defined $dlprg_configured length $dlprg_configured
MC/DC0%0/2
defined $dlprg_configured and length $dlprg_configured
defined $dlprg_configured length $dlprg_configured
Truth table0%0/3
A and B
A= defined $dlprg_configuredB= length $dlprg_configured
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $dlprg_configuredB= length $dlprg_configured
ABresult
0X0
100
111
464 0 my $funkyftp = CPAN::HandleConfig->safe_quote($dlprg_configured);
465 0 ▶ if ($dlprg eq "wget") {
Branch: 4 branches
BranchTrueFalseTotal
if ($dlprg eq 'wget') { } 0 0 0
elsif ($dlprg eq 'curl') { } 0 0 0
if ($dlprg eq 'wget') { } 0 0 0
elsif ($dlprg eq 'curl') { } 0 0 0
466 0 $src_switch = " -O \"$aslocal\"";
467 0 $stdout_redir = "";
468 } elsif ($dlprg eq 'curl') {
469 0 $src_switch = ' -L -f -s -S --netrc-optional';
470 0 $stdout_redir = " > \"$aslocal\"";
471 0 ▶ if ($proxy_vars->{http_proxy}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($proxy_vars->{"http_proxy"}) 0 0 0
if ($proxy_vars->{"http_proxy"}) 0 0 0
472 0 $src_switch .= qq{ -U "$proxy_vars->{proxy_user}:$proxy_vars->{proxy_pass}" -x "$proxy_vars->{http_proxy}"};
473 }
474 }
475 $CPAN::Frontend->myprint(
476 0 qq[
477 Trying with
478 $funkyftp$src_switch
479 to get
480 $url
481 ]);
482 0 my($system) =
483 "$funkyftp$src_switch \"$url\" $devnull$stdout_redir";
484 0 ▶ $self->debug("system[$system]") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
485 0 my($wstatus) = system($system);
486 0 ▶ if ($wstatus == 0) {
Branch: 2 branches
BranchTrueFalseTotal
if ($wstatus == 0) { } 0 0 0
if ($wstatus == 0) { } 0 0 0
487 0 return $aslocal;
488 } else {
489 0 my $estatus = $wstatus >> 8;
490 0 ▶ my $size = -f $aslocal ?
Branch: 2 branches
BranchTrueFalseTotal
-f $aslocal ? : 0 0 0
-f $aslocal ? : 0 0 0
491 ", left\n$aslocal with size ".-s _ :
492 "\nWarning: expected file [$aslocal] doesn't exist";
493 0 $CPAN::Frontend->myprint(qq{
494 Function system("$system")
495 returned status $estatus (wstat $wstatus)$size
496 });
497 }
498 } # DLPRG
499 } # curl, wget
500 0 return;
501 }
502  
503 #-> sub CPAN::FTP::localize ;
504 41 ▶sub localize_1995ff {
Subroutine localize_1995ff: called CC=50 SCAR=69.4
Pod undocumented
505 0 ▶ my($self,$file,$aslocal,$force,$with_defaults) = @_;
Subroutine localize_1995ff: not called CC=50 SCAR=69.4
Pod undocumented
506  
507 0 ▶ return $aslocal if $self->have_promising_aslocal($aslocal, $force);
Branch: 2 branches
BranchTrueFalseTotal
if $self->have_promising_aslocal($aslocal, $force) 0 41 41
if $self->have_promising_aslocal($aslocal, $force) 0 0 0
508 0 my($maybe_restore) = 0;
509 0 ▶ if (-f $aslocal) {
Branch: 2 branches
BranchTrueFalseTotal
if (-f $aslocal) 0 41 41
if (-f $aslocal) 0 0 0
510 0 rename $aslocal, "$aslocal.bak$$";
511 0 $maybe_restore++;
512 }
513  
514 0 my($aslocal_dir) = dirname($aslocal);
515 # Inheritance is not easier to manage than a few if/else branches
516 0 ▶ if ($CPAN::META->has_usable('LWP::UserAgent')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::META->has_usable("LWP::UserAgent")) 41 0 41
if ($CPAN::META->has_usable("LWP::UserAgent")) 0 0 0
517 0 ▶ unless ($Ua) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($CPAN::FTP::Ua) 9 32 41
unless ($CPAN::FTP::Ua) 0 0 0
518 0 CPAN::LWP::UserAgent->config;
519 0 eval {$Ua = CPAN::LWP::UserAgent->new;}; # Why is has_usable still not fit enough?
520 0 ▶ if ($@) {
Branch: 2 branches
BranchTrueFalseTotal
if ($@) { } 0 9 9
if ($@) { } 0 0 0
521 0 ▶ $CPAN::Frontend->mywarn("CPAN::LWP::UserAgent->new dies with $@\n")
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
522 if $CPAN::DEBUG;
523 } else {
524 0 my($var);
525 $Ua->proxy('ftp', $var)
526 0 ▶ if $var = $CPAN::Config->{ftp_proxy} || $ENV{ftp_proxy};
Branch: 2 branches
BranchTrueFalseTotal
if $var = $CPAN::Config->{"ftp_proxy"} || $ENV{"ftp_proxy"} 0 9 9
if $var = $CPAN::Config->{"ftp_proxy"} || $ENV{"ftp_proxy"} 0 0 0
Condition16%1/6
$CPAN::Config->{'ftp_proxy'} || $ENV{'ftp_proxy'}
l!l&&r!l&&!r
009
$CPAN::Config->{'ftp_proxy'} || $ENV{'ftp_proxy'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$CPAN::Config->{'ftp_proxy'} || $ENV{'ftp_proxy'}
$CPAN::Config->{'ftp_proxy'} $ENV{'ftp_proxy'}
MC/DC0%0/2
$CPAN::Config->{'ftp_proxy'} || $ENV{'ftp_proxy'}
$CPAN::Config->{'ftp_proxy'} $ENV{'ftp_proxy'}
Truth table33%1/3
A || B
A= $CPAN::Config->{'ftp_proxy'}B= $ENV{'ftp_proxy'}
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $CPAN::Config->{'ftp_proxy'}B= $ENV{'ftp_proxy'}
ABresult
1X1
011
000
527 $Ua->proxy('http', $var)
528 0 ▶ if $var = $CPAN::Config->{http_proxy} || $ENV{http_proxy};
Branch: 2 branches
BranchTrueFalseTotal
if $var = $CPAN::Config->{"http_proxy"} || $ENV{"http_proxy"} 0 9 9
if $var = $CPAN::Config->{"http_proxy"} || $ENV{"http_proxy"} 0 0 0
Condition16%1/6
$CPAN::Config->{'http_proxy'} || $ENV{'http_proxy'}
l!l&&r!l&&!r
009
$CPAN::Config->{'http_proxy'} || $ENV{'http_proxy'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$CPAN::Config->{'http_proxy'} || $ENV{'http_proxy'}
$CPAN::Config->{'http_proxy'} $ENV{'http_proxy'}
MC/DC0%0/2
$CPAN::Config->{'http_proxy'} || $ENV{'http_proxy'}
$CPAN::Config->{'http_proxy'} $ENV{'http_proxy'}
Truth table33%1/3
A || B
A= $CPAN::Config->{'http_proxy'}B= $ENV{'http_proxy'}
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $CPAN::Config->{'http_proxy'}B= $ENV{'http_proxy'}
ABresult
1X1
011
000
529 $Ua->no_proxy($var)
530 0 ▶ if $var = $CPAN::Config->{no_proxy} || $ENV{no_proxy};
Branch: 2 branches
BranchTrueFalseTotal
if $var = $CPAN::Config->{"no_proxy"} || $ENV{"no_proxy"} 0 9 9
if $var = $CPAN::Config->{"no_proxy"} || $ENV{"no_proxy"} 0 0 0
Condition16%1/6
$CPAN::Config->{'no_proxy'} || $ENV{'no_proxy'}
l!l&&r!l&&!r
009
$CPAN::Config->{'no_proxy'} || $ENV{'no_proxy'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$CPAN::Config->{'no_proxy'} || $ENV{'no_proxy'}
$CPAN::Config->{'no_proxy'} $ENV{'no_proxy'}
MC/DC0%0/2
$CPAN::Config->{'no_proxy'} || $ENV{'no_proxy'}
$CPAN::Config->{'no_proxy'} $ENV{'no_proxy'}
Truth table33%1/3
A || B
A= $CPAN::Config->{'no_proxy'}B= $ENV{'no_proxy'}
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $CPAN::Config->{'no_proxy'}B= $ENV{'no_proxy'}
ABresult
1X1
011
000
531 }
532 }
533 }
534 0 for my $prx (qw(ftp_proxy http_proxy no_proxy)) {
535 0 ▶ $ENV{$prx} = $CPAN::Config->{$prx} if $CPAN::Config->{$prx};
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::Config->{$prx} 0 123 123
if $CPAN::Config->{$prx} 0 0 0
536 }
537  
538 # Try the list of urls for each single object. We keep a record
539 # where we did get a file from
540 0 my(@reordered,$last);
541 0 my $ccurllist = $self->_get_urllist($with_defaults);
542 0 $last = $#$ccurllist;
543 0 ▶ if ($force & 2) { # local cpans probably out of date, don't reorder
Branch: 2 branches
BranchTrueFalseTotal
if ($force & 2) { } 27 14 41
if ($force & 2) { } 0 0 0
544 0 @reordered = (0..$last);
545 } else {
546 @reordered =
547 sort {
548 0 ▶ (substr($ccurllist->[$b],0,4) eq "file")
Condition0%0/12
(substr($ccurllist->[$b], 0, 4) eq 'file') <=> (substr($ccurllist->[$a], 0, 4) eq 'file') || defined $CPAN::FTP::ThesiteURL && ($ccurllist->[$b] eq $CPAN::FTP::ThesiteURL) <=> ($ccurllist->[$a] eq $CPAN::FTP::ThesiteURL)
l!l&&r!l&&!r
000
defined $CPAN::FTP::ThesiteURL and ($ccurllist->[$b] eq $CPAN::FTP::ThesiteURL) <=> ($ccurllist->[$a] eq $CPAN::FTP::ThesiteURL)
!ll&&!rl&&r
000
(substr($ccurllist->[$b], 0, 4) eq 'file') <=> (substr($ccurllist->[$a], 0, 4) eq 'file') || defined $CPAN::FTP::ThesiteURL && ($ccurllist->[$b] eq $CPAN::FTP::ThesiteURL) <=> ($ccurllist->[$a] eq $CPAN::FTP::ThesiteURL)
l!l&&r!l&&!r
000
defined $CPAN::FTP::ThesiteURL and ($ccurllist->[$b] eq $CPAN::FTP::ThesiteURL) <=> ($ccurllist->[$a] eq $CPAN::FTP::ThesiteURL)
!ll&&!rl&&r
000
MC/DC0%0/3
(substr($ccurllist->[$b], 0, 4) eq 'file') <=> (substr($ccurllist->[$a], 0, 4) eq 'file') || defined $CPAN::FTP::ThesiteURL && ($ccurllist->[$b] eq $CPAN::FTP::ThesiteURL) <=> ($ccurllist->[$a] eq $CPAN::FTP::ThesiteURL)
(substr($ccurllist->[$b], 0, 4) eq 'file') <=> (substr($ccurllist->[$a], 0, 4) eq 'file') defined $CPAN::FTP::ThesiteURL ($ccurllist->[$b] eq $CPAN::FTP::ThesiteURL) <=> ($ccurllist->[$a] eq $CPAN::FTP::ThesiteURL)
MC/DC0%0/3
(substr($ccurllist->[$b], 0, 4) eq 'file') <=> (substr($ccurllist->[$a], 0, 4) eq 'file') || defined $CPAN::FTP::ThesiteURL && ($ccurllist->[$b] eq $CPAN::FTP::ThesiteURL) <=> ($ccurllist->[$a] eq $CPAN::FTP::ThesiteURL)
(substr($ccurllist->[$b], 0, 4) eq 'file') <=> (substr($ccurllist->[$a], 0, 4) eq 'file') defined $CPAN::FTP::ThesiteURL ($ccurllist->[$b] eq $CPAN::FTP::ThesiteURL) <=> ($ccurllist->[$a] eq $CPAN::FTP::ThesiteURL)
Truth table0%0/4
A || B and C
A= (substr($ccurllist->[$b], 0, 4) eq 'file') <=> (substr($ccurllist->[$a], 0, 4) eq 'file')B= defined $CPAN::FTP::ThesiteURLC= ($ccurllist->[$b] eq $CPAN::FTP::ThesiteURL) <=> ($ccurllist->[$a] eq $CPAN::FTP::ThesiteURL)
ABCresult
1XX1
0111
00X0
0100
Truth table0%0/4
A || B and C
A= (substr($ccurllist->[$b], 0, 4) eq 'file') <=> (substr($ccurllist->[$a], 0, 4) eq 'file')B= defined $CPAN::FTP::ThesiteURLC= ($ccurllist->[$b] eq $CPAN::FTP::ThesiteURL) <=> ($ccurllist->[$a] eq $CPAN::FTP::ThesiteURL)
ABCresult
1XX1
0111
00X0
0100
549 <=>
550 (substr($ccurllist->[$a],0,4) eq "file")
551 or
552 defined($ThesiteURL)
553 and
554 ($ccurllist->[$b] eq $ThesiteURL)
555 <=>
556 ($ccurllist->[$a] eq $ThesiteURL)
557 } 0..$last;
558 }
559 0 my(@levels);
560 0 ▶ $Themethod ||= "";
Condition50%2/4
$CPAN::FTP::Themethod ||= ""
l!l
329
$CPAN::FTP::Themethod ||= ""
l!l
00
MC/DC100%1/1
$CPAN::FTP::Themethod ||= ""
$CPAN::FTP::Themethod
MC/DC0%0/1
$CPAN::FTP::Themethod ||= ""
$CPAN::FTP::Themethod
Truth table100%2/2
A
A= $CPAN::FTP::Themethod
Aresult
11
00
Truth table0%0/2
A
A= $CPAN::FTP::Themethod
Aresult
11
00
561 0 ▶ $self->debug("Themethod[$Themethod]reordered[@reordered]") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 41 41
if $CPAN::DEBUG 0 0 0
562 0 my @all_levels = (
563 ["dleasy", "file"],
564 ["dleasy"],
565 ["dlhard"],
566 ["dlhardest"],
567 ["dleasy", "http","defaultsites"],
568 ["dlhard", "http","defaultsites"],
569 ["dleasy", "ftp", "defaultsites"],
570 ["dlhard", "ftp", "defaultsites"],
571 ["dlhardest","", "defaultsites"],
572 );
573 0 ▶ if ($Themethod) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::FTP::Themethod) { } 32 9 41
if ($CPAN::FTP::Themethod) { } 0 0 0
574 0 @levels = grep {$_->[0] eq $Themethod} @all_levels;
575 0 push @levels, grep {$_->[0] ne $Themethod} @all_levels;
576 } else {
577 0 @levels = @all_levels;
578 }
579 0 my($levelno);
580 local $ENV{FTP_PASSIVE} =
581 exists $CPAN::Config->{ftp_passive} ?
582 0 ▶ $CPAN::Config->{ftp_passive} : 1;
Branch: 2 branches
BranchTrueFalseTotal
exists $CPAN::Config->{'ftp_passive'} ? : 35 6 41
exists $CPAN::Config->{'ftp_passive'} ? : 0 0 0
583 0 my $ret;
584 0 my $stats = $self->_new_stats($file);
585 0 LEVEL: for $levelno (0..$#levels) {
586 0 my $level_tuple = $levels[$levelno];
587 0 my($level,$scheme,$sitetag) = @$level_tuple;
588 0 ▶ $self->mymkpath($aslocal_dir) unless $scheme && "file" eq $scheme;
Branch: 2 branches
BranchTrueFalseTotal
unless $scheme and "file" eq $scheme 0 41 41
unless $scheme and "file" eq $scheme 0 0 0
Condition16%1/6
$scheme and "file" eq $scheme
!ll&&!rl&&r
0041
$scheme and "file" eq $scheme
!ll&&!rl&&r
000
MC/DC0%0/2
$scheme and "file" eq $scheme
$scheme "file" eq $scheme
MC/DC0%0/2
$scheme and "file" eq $scheme
$scheme "file" eq $scheme
Truth table33%1/3
A and B
A= $schemeB= "file" eq $scheme
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $schemeB= "file" eq $scheme
ABresult
0X0
100
111
589 0 ▶ my $defaultsites = $sitetag && $sitetag eq "defaultsites" && !@$ccurllist;
Condition16%2/12
$sitetag && $sitetag eq 'defaultsites' && !@$ccurllist
!ll&&!rl&&r
4100
$sitetag and $sitetag eq "defaultsites"
!ll&&!rl&&r
4100
$sitetag && $sitetag eq 'defaultsites' && !@$ccurllist
!ll&&!rl&&r
000
$sitetag and $sitetag eq "defaultsites"
!ll&&!rl&&r
000
MC/DC0%0/3
$sitetag && $sitetag eq 'defaultsites' && !@$ccurllist
$sitetag $sitetag eq "defaultsites" !@$ccurllist
MC/DC0%0/3
$sitetag && $sitetag eq 'defaultsites' && !@$ccurllist
$sitetag $sitetag eq "defaultsites" !@$ccurllist
Truth table25%1/4
A and B && not(C)
A= $sitetagB= $sitetag eq "defaultsites"C= !@$ccurllist
ABCresult
0XX0
10X0
1100
1111
Truth table0%0/4
A and B && not(C)
A= $sitetagB= $sitetag eq "defaultsites"C= !@$ccurllist
ABCresult
0XX0
10X0
1100
1111
590 0 my @urllist;
591 0 ▶ if ($defaultsites) {
Branch: 2 branches
BranchTrueFalseTotal
if ($defaultsites) { } 0 41 41
if ($defaultsites) { } 0 0 0
592 0 ▶ unless (defined $connect_to_internet_ok) {
Branch: 2 branches
BranchTrueFalseTotal
unless (defined $CPAN::FTP::connect_to_internet_ok) 0 0 0
unless (defined $CPAN::FTP::connect_to_internet_ok) 0 0 0
593 $CPAN::Frontend->myprint(sprintf qq{
594 I would like to connect to one of the following sites to get '%s':
595  
596 %s
597 },
598 $file,
599 0 join("",map { " ".$_->text."\n" } @CPAN::Defaultsites),
600 );
601 0 my $answer = CPAN::Shell::colorable_makemaker_prompt("Is it OK to try to connect to the Internet?", "yes");
602 0 ▶ if ($answer =~ /^y/i) {
Branch: 2 branches
BranchTrueFalseTotal
if ($answer =~ /^y/i) { } 0 0 0
if ($answer =~ /^y/i) { } 0 0 0
603 0 $connect_to_internet_ok = 1;
604 } else {
605 0 $connect_to_internet_ok = 0;
606 }
607 }
608 0 ▶ if ($connect_to_internet_ok) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::FTP::connect_to_internet_ok) { } 0 0 0
if ($CPAN::FTP::connect_to_internet_ok) { } 0 0 0
609 0 @urllist = @CPAN::Defaultsites;
610 } else {
611 0 my $sleep = 2;
612 # the tricky thing about dying here is that everybody
613 # believes that calls to exists() or all_objects() are
614 # safe.
615 0 require CPAN::Exception::blocked_urllist;
616 0 die CPAN::Exception::blocked_urllist->new;
617 }
618 } else { # ! $defaultsites
619 0 ▶ my @host_seq = $level =~ /dleasy/ ?
Branch: 2 branches
BranchTrueFalseTotal
$level =~ /dleasy/ ? : 41 0 41
$level =~ /dleasy/ ? : 0 0 0
620 @reordered : 0..$last; # reordered has file and $Thesiteurl first
621 0 @urllist = map { $ccurllist->[$_] } @host_seq;
622 }
623 0 ▶ $self->debug("synth. urllist[@urllist]") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 41 41
if $CPAN::DEBUG 0 0 0
624 0 my $aslocal_tempfile = $aslocal . ".tmp" . $$;
625 0 ▶ if (my $recommend = $self->_recommend_url_for($file,\@urllist)) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $recommend = $self->_recommend_url_for($file, \@urllist)) 7 34 41
if (my $recommend = $self->_recommend_url_for($file, \@urllist)) 0 0 0
626 0 @urllist = grep { $_ ne $recommend } @urllist;
627 0 unshift @urllist, $recommend;
628 }
629 0 ▶ $self->debug("synth. urllist[@urllist]") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 41 41
if $CPAN::DEBUG 0 0 0
630 0 $ret = $self->hostdlxxx($level,$scheme,\@urllist,$file,$aslocal_tempfile,$stats);
631 0 ▶ if ($ret) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ret) { } 41 0 41
if ($ret) { } 0 0 0
632 0 ▶ CPAN->debug("ret[$ret]aslocal[$aslocal]") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 41 41
if $CPAN::DEBUG 0 0 0
633 0 ▶ if ($ret eq $aslocal_tempfile) {
Branch: 4 branches
BranchTrueFalseTotal
if ($ret eq $aslocal_tempfile) { } 0 41 41
elsif (-f $ret and $scheme eq 'file') { } 41 0 41
if ($ret eq $aslocal_tempfile) { } 0 0 0
elsif (-f $ret and $scheme eq 'file') { } 0 0 0
634 # if we got it exactly as we asked for, only then we
635 # want to rename
636 0 ▶ rename $aslocal_tempfile, $aslocal
Branch: 2 branches
BranchTrueFalseTotal
rename $aslocal_tempfile, $aslocal or $CPAN::Frontend->mydie('Error while trying to rename ' . "'${ret}' to '${aslocal}': $!") 0 0 0
rename $aslocal_tempfile, $aslocal or $CPAN::Frontend->mydie('Error while trying to rename ' . "'${ret}' to '${aslocal}': $!") 0 0 0
637 or $CPAN::Frontend->mydie("Error while trying to rename ".
638 "'$ret' to '$aslocal': $!");
639 0 $ret = $aslocal;
640 }
641 ▶ elsif (-f $ret && $scheme eq 'file' ) {
Condition16%1/6
-f $ret and $scheme eq "file"
!ll&&!rl&&r
0041
-f $ret and $scheme eq "file"
!ll&&!rl&&r
000
MC/DC0%0/2
-f $ret and $scheme eq "file"
-f $ret $scheme eq "file"
MC/DC0%0/2
-f $ret and $scheme eq "file"
-f $ret $scheme eq "file"
Truth table33%1/3
A and B
A= -f $retB= $scheme eq "file"
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= -f $retB= $scheme eq "file"
ABresult
0X0
100
111
642 # it's a local file, so there's nothing left to do, we
643 # let them read from where it is
644 }
645 0 $Themethod = $level;
646 0 my $now = time;
647 # utime $now, $now, $aslocal; # too bad, if we do that, we
648 # might alter a local mirror
649 0 ▶ $self->debug("level[$level]") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 41 41
if $CPAN::DEBUG 0 0 0
650 0 last LEVEL;
651 } else {
652 0 unlink $aslocal_tempfile;
653 0 ▶ last if $CPAN::Signal; # need to cleanup
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::Signal 0 0 0
if $CPAN::Signal 0 0 0
654 }
655 }
656 0 ▶ if ($ret) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ret) 41 0 41
if ($ret) 0 0 0
657 0 $stats->{filesize} = -s $ret;
658 }
659 0 ▶ $self->debug("before _add_to_statistics") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 41 41
if $CPAN::DEBUG 0 0 0
660 0 $self->_add_to_statistics($stats);
661 0 ▶ $self->debug("after _add_to_statistics") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 41 41
if $CPAN::DEBUG 0 0 0
662 0 ▶ if ($ret) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ret) 41 0 41
if ($ret) 0 0 0
663 0 unlink "$aslocal.bak$$";
664 0 return $ret;
665 }
666 0 ▶ unless ($CPAN::Signal) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($CPAN::Signal) 0 0 0
unless ($CPAN::Signal) 0 0 0
667 0 my(@mess);
668 0 local $" = " ";
669 0 ▶ if (@{$CPAN::Config->{urllist}}) {
Branch: 2 branches
BranchTrueFalseTotal
if (@{$CPAN::Config->{'urllist'};}) { } 0 0 0
if (@{$CPAN::Config->{'urllist'};}) { } 0 0 0
670 push @mess,
671 qq{Please check, if the URLs I found in your configuration file \(}.
672 0 join(", ", @{$CPAN::Config->{urllist}}).
673 qq{\) are valid.};
674 } else {
675 0 push @mess, qq{Your urllist is empty!};
676 }
677 0 push @mess, qq{The urllist can be edited.},
678 qq{E.g. with 'o conf urllist push ftp://myurl/'};
679 0 $CPAN::Frontend->mywarn(Text::Wrap::wrap("","","@mess"). "\n\n");
680 0 $CPAN::Frontend->mydie("Could not fetch $file\n");
681 }
682 0 ▶ if ($maybe_restore) {
Branch: 2 branches
BranchTrueFalseTotal
if ($maybe_restore) 0 0 0
if ($maybe_restore) 0 0 0
683 0 rename "$aslocal.bak$$", $aslocal;
684 0 $CPAN::Frontend->myprint("Trying to get away with old file:\n" .
685 $self->ls($aslocal) . "\n");
686 0 return $aslocal;
687 }
688 0 return;
689 }
690  
691 0 ▶sub mymkpath {
Subroutine mymkpath: not called CC=2 SCAR=17.9
Pod undocumented
692 0 ▶ my($self, $aslocal_dir) = @_;
Subroutine mymkpath: not called CC=2 SCAR=17.9
Pod undocumented
693 0 mkpath($aslocal_dir);
694 0 ▶ $CPAN::Frontend->mywarn(qq{Warning: You are not allowed to write into }.
Branch: 2 branches
BranchTrueFalseTotal
unless -w $aslocal_dir 0 0 0
unless -w $aslocal_dir 0 0 0
695 qq{directory "$aslocal_dir".
696 I\'ll continue, but if you encounter problems, they may be due
697 to insufficient permissions.\n}) unless -w $aslocal_dir;
698 }
699  
700 41 ▶sub hostdlxxx {
Subroutine hostdlxxx: called CC=2 SCAR=9.9
Pod undocumented
701 0 ▶ my $self = shift;
Subroutine hostdlxxx: not called CC=2 SCAR=9.9
Pod undocumented
702 0 my $level = shift;
703 0 my $scheme = shift;
704 0 my $h = shift;
705 0 ▶ $h = [ grep /^\Q$scheme\E:/, @$h ] if $scheme;
Branch: 2 branches
BranchTrueFalseTotal
if $scheme 41 0 41
if $scheme 0 0 0
706 0 my $method = "host$level";
707 0 $self->$method($h, @_);
708 }
709  
710 41 ▶sub _set_attempt {
Subroutine _set_attempt: called CC=1 SCAR=1.2
711 0 ▶ my($self,$stats,$method,$url) = @_;
Subroutine _set_attempt: not called CC=1 SCAR=1.2
712 0 push @{$stats->{attempts}}, {
713 method => $method,
714 start => _mytime,
715 url => $url,
716 };
717 }
718  
719 # package CPAN::FTP;
720 41 ▶sub hostdleasy { #called from hostdlxxx
Subroutine hostdleasy: called CC=61 SCAR=80.4
Pod undocumented
721 0 ▶ my($self,$host_seq,$file,$aslocal,$stats) = @_;
Subroutine hostdleasy: not called CC=61 SCAR=80.4
Pod undocumented
722 0 my($ro_url);
723 0 HOSTEASY: for $ro_url (@$host_seq) {
724 0 $self->_set_attempt($stats,"dleasy",$ro_url);
725 0 my $url = "$ro_url$file";
726 0 ▶ $self->debug("localizing perlish[$url]") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 41 41
if $CPAN::DEBUG 0 0 0
727 0 ▶ if ($url =~ /^file:/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($url =~ /^file:/) 41 0 41
if ($url =~ /^file:/) 0 0 0
728 0 my $l;
729 0 ▶ if ($CPAN::META->has_inst('URI::URL')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::META->has_inst('URI::URL')) { } 41 0 41
if ($CPAN::META->has_inst('URI::URL')) { } 0 0 0
730 0 my $u = URI::URL->new($url);
731 0 $l = $u->file;
732 } else { # works only on Unix, is poorly constructed, but
733 # hopefully better than nothing.
734 # RFC 1738 says fileurl BNF is
735 # fileurl = "file://" [ host | "localhost" ] "/" fpath
736 # Thanks to "Mark D. Baushke" <mdb@cisco.com> for
737 # the code
738 0 ($l = $url) =~ s|^file://[^/]*/|/|; # discard the host part
739 0 $l =~ s|^file:||; # assume they
740 # meant
741 # file://localhost
742 0 ▶ $l =~ s|^/||s
Branch: 2 branches
BranchTrueFalseTotal
if not -f $l and $l =~ m[^/\w:] 0 0 0
if not -f $l and $l =~ m[^/\w:] 0 0 0
Condition0%0/6
not -f $l and $l =~ m[^/\w:]
!ll&&!rl&&r
000
not -f $l and $l =~ m[^/\w:]
!ll&&!rl&&r
000
MC/DC0%0/2
not -f $l and $l =~ m[^/\w:]
not -f $l $l =~ m[^/\w:]
MC/DC0%0/2
not -f $l and $l =~ m[^/\w:]
not -f $l $l =~ m[^/\w:]
Truth table0%0/3
not(A) and B
A= not -f $lB= $l =~ m[^/\w:]
ABresult
0X0
100
111
Truth table0%0/3
not(A) and B
A= not -f $lB= $l =~ m[^/\w:]
ABresult
0X0
100
111
743 if ! -f $l && $l =~ m|^/\w:|; # e.g. /P:
744 }
745 0 ▶ $self->debug("local file[$l]") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 41 41
if $CPAN::DEBUG 0 0 0
746 0 ▶ if ( -f $l && -r _) {
Branch: 2 branches
BranchTrueFalseTotal
if (-f $l and -r _) 28 13 41
if (-f $l and -r _) 0 0 0
Condition33%2/6
-f $l and -r _
!ll&&!rl&&r
13028
-f $l and -r _
!ll&&!rl&&r
000
MC/DC50%1/2
-f $l and -r _
-f $l -r _
MC/DC0%0/2
-f $l and -r _
-f $l -r _
Truth table66%2/3
A and B
A= -f $lB= -r _
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= -f $lB= -r _
ABresult
0X0
100
111
747 0 $ThesiteURL = $ro_url;
748 0 return $l;
749 }
750 # If request is for a compressed file and we can find the
751 # uncompressed file also, return the path of the uncompressed file
752 # otherwise, decompress it and return the resulting path
753 0 ▶ if ($l =~ /(.+)\.gz$/) {
Branch: 6 branches
BranchTrueFalseTotal
if ($l =~ /(.+)\.gz$/) { } 13 0 13
elsif (-f $l and -r _) { } 0 0 0
elsif (-f "$l.gz") { } 0 0 0
if ($l =~ /(.+)\.gz$/) { } 0 0 0
elsif (-f $l and -r _) { } 0 0 0
elsif (-f "$l.gz") { } 0 0 0
754 0 my $ungz = $1;
755 0 ▶ if ( -f $ungz && -r _) {
Branch: 4 branches
BranchTrueFalseTotal
if (-f $ungz and -r _) { } 13 0 13
elsif (-f $l and -r _) { } 0 0 0
if (-f $ungz and -r _) { } 0 0 0
elsif (-f $l and -r _) { } 0 0 0
Condition16%1/6
-f $ungz and -r _
!ll&&!rl&&r
0013
-f $ungz and -r _
!ll&&!rl&&r
000
MC/DC0%0/2
-f $ungz and -r _
-f $ungz -r _
MC/DC0%0/2
-f $ungz and -r _
-f $ungz -r _
Truth table33%1/3
A and B
A= -f $ungzB= -r _
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= -f $ungzB= -r _
ABresult
0X0
100
111
756 0 $ThesiteURL = $ro_url;
757 0 return $ungz;
758 }
759 ▶ elsif (-f $l && -r _) {
Condition0%0/6
-f $l and -r _
!ll&&!rl&&r
000
-f $l and -r _
!ll&&!rl&&r
000
MC/DC0%0/2
-f $l and -r _
-f $l -r _
MC/DC0%0/2
-f $l and -r _
-f $l -r _
Truth table0%0/3
A and B
A= -f $lB= -r _
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= -f $lB= -r _
ABresult
0X0
100
111
760 0 eval { CPAN::Tarzip->new($l)->gunzip($aslocal) };
761 0 ▶ if ( -f $aslocal && -s _) {
Branch: 6 branches
BranchTrueFalseTotal
if (-f $aslocal and -s _) { } 0 0 0
elsif (not -s $aslocal) { } 0 0 0
elsif (-f $l) { } 0 0 0
if (-f $aslocal and -s _) { } 0 0 0
elsif (not -s $aslocal) { } 0 0 0
elsif (-f $l) { } 0 0 0
Condition0%0/6
-f $aslocal and -s _
!ll&&!rl&&r
000
-f $aslocal and -s _
!ll&&!rl&&r
000
MC/DC0%0/2
-f $aslocal and -s _
-f $aslocal -s _
MC/DC0%0/2
-f $aslocal and -s _
-f $aslocal -s _
Truth table0%0/3
A and B
A= -f $aslocalB= -s _
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= -f $aslocalB= -s _
ABresult
0X0
100
111
762 0 $ThesiteURL = $ro_url;
763 0 return $aslocal;
764 }
765 elsif (! -s $aslocal) {
766 0 unlink $aslocal;
767 }
768 elsif (-f $l) {
769 0 ▶ $CPAN::Frontend->mywarn("Error decompressing '$l': $@\n")
Branch: 2 branches
BranchTrueFalseTotal
if $@ 0 0 0
if $@ 0 0 0
770 if $@;
771 0 return;
772 }
773 }
774 }
775 # Otherwise, return the local file path if it exists
776 ▶ elsif ( -f $l && -r _) {
Condition0%0/6
-f $l and -r _
!ll&&!rl&&r
000
-f $l and -r _
!ll&&!rl&&r
000
MC/DC0%0/2
-f $l and -r _
-f $l -r _
MC/DC0%0/2
-f $l and -r _
-f $l -r _
Truth table0%0/3
A and B
A= -f $lB= -r _
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= -f $lB= -r _
ABresult
0X0
100
111
777 0 $ThesiteURL = $ro_url;
778 0 return $l;
779 }
780 # If we can't find it, but there is a compressed version
781 # of it, then decompress it
782 elsif (-f "$l.gz") {
783 0 ▶ $self->debug("found compressed $l.gz") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
784 0 eval { CPAN::Tarzip->new("$l.gz")->gunzip($aslocal) };
785 0 ▶ if ( -f $aslocal) {
Branch: 2 branches
BranchTrueFalseTotal
if (-f $aslocal) { } 0 0 0
if (-f $aslocal) { } 0 0 0
786 0 $ThesiteURL = $ro_url;
787 0 return $aslocal;
788 }
789 else {
790 0 ▶ $CPAN::Frontend->mywarn("Error decompressing '$l': $@\n")
Branch: 2 branches
BranchTrueFalseTotal
if $@ 0 0 0
if $@ 0 0 0
791 if $@;
792 0 return;
793 }
794 }
795 0 $CPAN::Frontend->mywarn("Could not find '$l'\n");
796 }
797 0 ▶ $self->debug("it was not a file URL") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
798 0 ▶ if ($CPAN::META->has_usable('LWP')) {
Branch: 4 branches
BranchTrueFalseTotal
if ($CPAN::META->has_usable('LWP')) { } 0 0 0
elsif ($url =~ /^http:/i and $CPAN::META->has_usable('HTTP::Tiny')) { } 0 0 0
if ($CPAN::META->has_usable('LWP')) { } 0 0 0
elsif ($url =~ /^http:/i and $CPAN::META->has_usable('HTTP::Tiny')) { } 0 0 0
799 0 $CPAN::Frontend->myprint("Fetching with LWP:\n$url\n");
800 0 ▶ unless ($Ua) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($CPAN::FTP::Ua) 0 0 0
unless ($CPAN::FTP::Ua) 0 0 0
801 0 CPAN::LWP::UserAgent->config;
802 0 eval { $Ua = CPAN::LWP::UserAgent->new; };
803 0 ▶ if ($@) {
Branch: 2 branches
BranchTrueFalseTotal
if ($@) 0 0 0
if ($@) 0 0 0
804 0 $CPAN::Frontend->mywarn("CPAN::LWP::UserAgent->new dies with $@\n");
805 }
806 }
807 0 my $res = $Ua->mirror($url, $aslocal);
808 0 ▶ if ($res->is_success) {
Branch: 4 branches
BranchTrueFalseTotal
if ($res->is_success) { } 0 0 0
elsif (not $url =~ /\.gz(?!\n)\Z/) { } 0 0 0
if ($res->is_success) { } 0 0 0
elsif (not $url =~ /\.gz(?!\n)\Z/) { } 0 0 0
809 0 $ThesiteURL = $ro_url;
810 0 my $now = time;
811 0 utime $now, $now, $aslocal; # download time is more
812 # important than upload
813 # time
814 0 return $aslocal;
815 } elsif ($url !~ /\.gz(?!\n)\Z/) {
816 0 my $gzurl = "$url.gz";
817 0 $CPAN::Frontend->myprint("Fetching with LWP:\n$gzurl\n");
818 0 $res = $Ua->mirror($gzurl, "$aslocal.gz");
819 0 ▶ if ($res->is_success) {
Branch: 2 branches
BranchTrueFalseTotal
if ($res->is_success) 0 0 0
if ($res->is_success) 0 0 0
820 0 ▶ if (eval {CPAN::Tarzip->new("$aslocal.gz")->gunzip($aslocal)}) {
Branch: 2 branches
BranchTrueFalseTotal
if (eval { do { "CPAN::Tarzip"->new("$aslocal.gz")->gunzip($aslocal) } }) 0 0 0
if (eval { do { "CPAN::Tarzip"->new("$aslocal.gz")->gunzip($aslocal) } }) 0 0 0
821 0 $ThesiteURL = $ro_url;
822 0 return $aslocal;
823 }
824 }
825 } else {
826 0 $CPAN::Frontend->myprint(sprintf(
827 "LWP failed with code[%s] message[%s]\n",
828 $res->code,
829 $res->message,
830 ));
831 # Alan Burlison informed me that in firewall environments
832 # Net::FTP can still succeed where LWP fails. So we do not
833 # skip Net::FTP anymore when LWP is available.
834 }
835 ▶ } elsif ($url =~ /^http:/i && $CPAN::META->has_usable('HTTP::Tiny')) {
Condition0%0/6
$url =~ /^http:/i and $CPAN::META->has_usable("HTTP::Tiny")
!ll&&!rl&&r
000
$url =~ /^http:/i and $CPAN::META->has_usable("HTTP::Tiny")
!ll&&!rl&&r
000
MC/DC0%0/2
$url =~ /^http:/i and $CPAN::META->has_usable("HTTP::Tiny")
$url =~ /^http:/i $CPAN::META->has_usable("HTTP::Tiny")
MC/DC0%0/2
$url =~ /^http:/i and $CPAN::META->has_usable("HTTP::Tiny")
$url =~ /^http:/i $CPAN::META->has_usable("HTTP::Tiny")
Truth table0%0/3
A and B
A= $url =~ /^http:/iB= $CPAN::META->has_usable("HTTP::Tiny")
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $url =~ /^http:/iB= $CPAN::META->has_usable("HTTP::Tiny")
ABresult
0X0
100
111
836 0 require CPAN::HTTP::Client;
837 my $chc = CPAN::HTTP::Client->new(
838 proxy => $CPAN::Config->{http_proxy} || $ENV{http_proxy},
839 no_proxy => $CPAN::Config->{no_proxy} || $ENV{no_proxy},
840 0 ▶ );
Condition0%0/12
$CPAN::Config->{'http_proxy'} || $ENV{'http_proxy'}
l!l&&r!l&&!r
000
$CPAN::Config->{'no_proxy'} || $ENV{'no_proxy'}
l!l&&r!l&&!r
000
$CPAN::Config->{'http_proxy'} || $ENV{'http_proxy'}
l!l&&r!l&&!r
000
$CPAN::Config->{'no_proxy'} || $ENV{'no_proxy'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$CPAN::Config->{'http_proxy'} || $ENV{'http_proxy'}
$CPAN::Config->{'http_proxy'} $ENV{'http_proxy'}
MC/DC0%0/2
$CPAN::Config->{'no_proxy'} || $ENV{'no_proxy'}
$CPAN::Config->{'no_proxy'} $ENV{'no_proxy'}
MC/DC0%0/2
$CPAN::Config->{'http_proxy'} || $ENV{'http_proxy'}
$CPAN::Config->{'http_proxy'} $ENV{'http_proxy'}
MC/DC0%0/2
$CPAN::Config->{'no_proxy'} || $ENV{'no_proxy'}
$CPAN::Config->{'no_proxy'} $ENV{'no_proxy'}
Truth table0%0/3
A || B
A= $CPAN::Config->{'http_proxy'}B= $ENV{'http_proxy'}
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $CPAN::Config->{'no_proxy'}B= $ENV{'no_proxy'}
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $CPAN::Config->{'http_proxy'}B= $ENV{'http_proxy'}
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $CPAN::Config->{'no_proxy'}B= $ENV{'no_proxy'}
ABresult
1X1
011
000
841 0 ▶ for my $try ( $url, ( $url !~ /\.gz(?!\n)\Z/ ? "$url.gz" : () ) ) {
Branch: 2 branches
BranchTrueFalseTotal
!($url =~ /\.gz(?!\n)\Z/) ? : 0 0 0
!($url =~ /\.gz(?!\n)\Z/) ? : 0 0 0
842 0 $CPAN::Frontend->myprint("Fetching with HTTP::Tiny:\n$try\n");
843 0 my $res = eval { $chc->mirror($try, $aslocal) };
844 0 ▶ if ( $res && $res->{success} ) {
Branch: 6 branches
BranchTrueFalseTotal
if ($res and $res->{'success'}) { } 0 0 0
elsif ($res and $res->{'status'} ne '599') { } 0 0 0
elsif ($res and $res->{'status'} eq '599') { } 0 0 0
if ($res and $res->{'success'}) { } 0 0 0
elsif ($res and $res->{'status'} ne '599') { } 0 0 0
elsif ($res and $res->{'status'} eq '599') { } 0 0 0
Condition0%0/6
$res and $res->{"success"}
!ll&&!rl&&r
000
$res and $res->{"success"}
!ll&&!rl&&r
000
MC/DC0%0/2
$res and $res->{"success"}
$res $res->{"success"}
MC/DC0%0/2
$res and $res->{"success"}
$res $res->{"success"}
Truth table0%0/3
A and B
A= $resB= $res->{"success"}
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $resB= $res->{"success"}
ABresult
0X0
100
111
845 0 $ThesiteURL = $ro_url;
846 0 my $now = time;
847 0 utime $now, $now, $aslocal; # download time is more
848 # important than upload
849 # time
850 0 return $aslocal;
851 }
852 ▶ elsif ( $res && $res->{status} ne '599') {
Condition0%0/6
$res and $res->{"status"} ne 599
!ll&&!rl&&r
000
$res and $res->{"status"} ne 599
!ll&&!rl&&r
000
MC/DC0%0/2
$res and $res->{"status"} ne 599
$res $res->{"status"} ne 599
MC/DC0%0/2
$res and $res->{"status"} ne 599
$res $res->{"status"} ne 599
Truth table0%0/3
A and B
A= $resB= $res->{"status"} ne 599
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $resB= $res->{"status"} ne 599
ABresult
0X0
100
111
853 $CPAN::Frontend->myprint(sprintf(
854 "HTTP::Tiny failed with code[%s] message[%s]\n",
855 $res->{status},
856 $res->{reason},
857 )
858 0 );
859 }
860 ▶ elsif ( $res && $res->{status} eq '599') {
Condition0%0/6
$res and $res->{"status"} eq 599
!ll&&!rl&&r
000
$res and $res->{"status"} eq 599
!ll&&!rl&&r
000
MC/DC0%0/2
$res and $res->{"status"} eq 599
$res $res->{"status"} eq 599
MC/DC0%0/2
$res and $res->{"status"} eq 599
$res $res->{"status"} eq 599
Truth table0%0/3
A and B
A= $resB= $res->{"status"} eq 599
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $resB= $res->{"status"} eq 599
ABresult
0X0
100
111
861 $CPAN::Frontend->myprint(sprintf(
862 "HTTP::Tiny failed with an internal error: %s\n",
863 $res->{content},
864 )
865 0 );
866 }
867 else {
868 0 ▶ my $err = $@ || 'Unknown error';
Condition0%0/4
$@ || 'Unknown error'
l!l
00
$@ || 'Unknown error'
l!l
00
MC/DC0%0/1
$@ || 'Unknown error'
$@
MC/DC0%0/1
$@ || 'Unknown error'
$@
Truth table0%0/2
A
A= $@
Aresult
11
00
Truth table0%0/2
A
A= $@
Aresult
11
00
869 0 $CPAN::Frontend->myprint(sprintf(
870 "Error downloading with HTTP::Tiny: %s\n", $err
871 )
872 );
873 }
874 }
875 }
876 0 ▶ return if $CPAN::Signal;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::Signal 0 0 0
if $CPAN::Signal 0 0 0
877 0 ▶ if ($url =~ m|^ftp://(.*?)/(.*)/(.*)|) {
Branch: 2 branches
BranchTrueFalseTotal
if ($url =~ m[^ftp://(.*?)/(.*)/(.*)]) 0 0 0
if ($url =~ m[^ftp://(.*?)/(.*)/(.*)]) 0 0 0
878 # that's the nice and easy way thanks to Graham
879 0 ▶ $self->debug("recognized ftp") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
880 0 my($host,$dir,$getfile) = ($1,$2,$3);
881 0 ▶ if ($CPAN::META->has_usable('Net::FTP')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::META->has_usable('Net::FTP')) { } 0 0 0
if ($CPAN::META->has_usable('Net::FTP')) { } 0 0 0
882 0 $dir =~ s|/+|/|g;
883 0 $CPAN::Frontend->myprint("Fetching with Net::FTP:\n$url\n");
884 0 ▶ $self->debug("getfile[$getfile]dir[$dir]host[$host]" .
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
885 "aslocal[$aslocal]") if $CPAN::DEBUG;
886 0 ▶ if (CPAN::FTP->ftp_get($host,$dir,$getfile,$aslocal)) {
Branch: 2 branches
BranchTrueFalseTotal
if ("CPAN::FTP"->ftp_get($host, $dir, $getfile, $aslocal)) 0 0 0
if ("CPAN::FTP"->ftp_get($host, $dir, $getfile, $aslocal)) 0 0 0
887 0 $ThesiteURL = $ro_url;
888 0 return $aslocal;
889 }
890 0 ▶ if ($aslocal !~ /\.gz(?!\n)\Z/) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($aslocal =~ /\.gz(?!\n)\Z/) 0 0 0
unless ($aslocal =~ /\.gz(?!\n)\Z/) 0 0 0
891 0 my $gz = "$aslocal.gz";
892 0 $CPAN::Frontend->myprint("Fetching with Net::FTP\n$url.gz\n");
893 0 ▶ if (CPAN::FTP->ftp_get($host,
Branch: 2 branches
BranchTrueFalseTotal
if ("CPAN::FTP"->ftp_get($host, $dir, "$getfile.gz", $gz) and eval { do { "CPAN::Tarzip"->new($gz)->gunzip($aslocal) } }) 0 0 0
if ("CPAN::FTP"->ftp_get($host, $dir, "$getfile.gz", $gz) and eval { do { "CPAN::Tarzip"->new($gz)->gunzip($aslocal) } }) 0 0 0
Condition0%0/6
"CPAN::FTP"->ftp_get($host, $dir, "$getfile.gz", $gz) and eval { do { "CPAN::Tarzip"->new($gz)->gunzip($aslocal) } }
!ll&&!rl&&r
000
"CPAN::FTP"->ftp_get($host, $dir, "$getfile.gz", $gz) and eval { do { "CPAN::Tarzip"->new($gz)->gunzip($aslocal) } }
!ll&&!rl&&r
000
MC/DC0%0/2
"CPAN::FTP"->ftp_get($host, $dir, "$getfile.gz", $gz) and eval { do { "CPAN::Tarzip"->new($gz)->gunzip($aslocal) } }
"CPAN::FTP"->ftp_get($host, $dir, "$getfile.gz", $gz) eval { do { "CPAN::Tarzip"->new($gz)->gunzip($aslocal) } }
MC/DC0%0/2
"CPAN::FTP"->ftp_get($host, $dir, "$getfile.gz", $gz) and eval { do { "CPAN::Tarzip"->new($gz)->gunzip($aslocal) } }
"CPAN::FTP"->ftp_get($host, $dir, "$getfile.gz", $gz) eval { do { "CPAN::Tarzip"->new($gz)->gunzip($aslocal) } }
Truth table0%0/3
A and B
A= "CPAN::FTP"->ftp_get($host, $dir, "$getfile.gz", $gz)B= eval { do { "CPAN::Tarzip"->new($gz)->gunzip($aslocal) } }
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= "CPAN::FTP"->ftp_get($host, $dir, "$getfile.gz", $gz)B= eval { do { "CPAN::Tarzip"->new($gz)->gunzip($aslocal) } }
ABresult
0X0
100
111
894 $dir,
895 "$getfile.gz",
896 $gz) &&
897 0 eval{CPAN::Tarzip->new($gz)->gunzip($aslocal)}
898 ) {
899 0 $ThesiteURL = $ro_url;
900 0 return $aslocal;
901 }
902 }
903 # next HOSTEASY;
904 } else {
905 0 ▶ CPAN->debug("Net::FTP does not count as usable atm") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
906 }
907 }
908 0 ▶ if (
Branch: 2 branches
BranchTrueFalseTotal
if (UNIVERSAL::can($ro_url, "text") and $ro_url->{"FROM"} eq "USER") 0 0 0
if (UNIVERSAL::can($ro_url, "text") and $ro_url->{"FROM"} eq "USER") 0 0 0
Condition0%0/6
UNIVERSAL::can($ro_url, "text") and $ro_url->{"FROM"} eq "USER"
!ll&&!rl&&r
000
UNIVERSAL::can($ro_url, "text") and $ro_url->{"FROM"} eq "USER"
!ll&&!rl&&r
000
MC/DC0%0/2
UNIVERSAL::can($ro_url, "text") and $ro_url->{"FROM"} eq "USER"
UNIVERSAL::can($ro_url, "text") $ro_url->{"FROM"} eq "USER"
MC/DC0%0/2
UNIVERSAL::can($ro_url, "text") and $ro_url->{"FROM"} eq "USER"
UNIVERSAL::can($ro_url, "text") $ro_url->{"FROM"} eq "USER"
Truth table0%0/3
A and B
A= UNIVERSAL::can($ro_url, "text")B= $ro_url->{"FROM"} eq "USER"
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= UNIVERSAL::can($ro_url, "text")B= $ro_url->{"FROM"} eq "USER"
ABresult
0X0
100
111
909 UNIVERSAL::can($ro_url,"text")
910 and
911 $ro_url->{FROM} eq "USER"
912 ) {
913 ##address #17973: default URLs should not try to override
914 ##user-defined URLs just because LWP is not available
915 0 my $ret = $self->hostdlhard([$ro_url],$file,$aslocal,$stats);
916 0 ▶ return $ret if $ret;
Branch: 2 branches
BranchTrueFalseTotal
if $ret 0 0 0
if $ret 0 0 0
917 }
918 0 ▶ return if $CPAN::Signal;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::Signal 0 0 0
if $CPAN::Signal 0 0 0
919 }
920 }
921  
922 # package CPAN::FTP;
923 0 ▶sub hostdlhard {
Subroutine hostdlhard: not called CC=28 SCAR=67.0
Pod undocumented
924 0 ▶ my($self,$host_seq,$file,$aslocal,$stats) = @_;
Subroutine hostdlhard: not called CC=28 SCAR=67.0
Pod undocumented
925  
926 # Came back if Net::FTP couldn't establish connection (or
927 # failed otherwise) Maybe they are behind a firewall, but they
928 # gave us a socksified (or other) ftp program...
929  
930 0 my($ro_url);
931 0 ▶ my($devnull) = $CPAN::Config->{devnull} || "";
Condition0%0/4
$CPAN::Config->{'devnull'} || ''
l!l
00
$CPAN::Config->{'devnull'} || ''
l!l
00
MC/DC0%0/1
$CPAN::Config->{'devnull'} || ''
$CPAN::Config->{'devnull'}
MC/DC0%0/1
$CPAN::Config->{'devnull'} || ''
$CPAN::Config->{'devnull'}
Truth table0%0/2
A
A= $CPAN::Config->{'devnull'}
Aresult
11
00
Truth table0%0/2
A
A= $CPAN::Config->{'devnull'}
Aresult
11
00
932 # < /dev/null ";
933 0 my($aslocal_dir) = dirname($aslocal);
934 0 mkpath($aslocal_dir);
935 0 my $some_dl_success = 0;
936 0 my $any_attempt = 0;
937 0 HOSTHARD: for $ro_url (@$host_seq) {
938 0 $self->_set_attempt($stats,"dlhard",$ro_url);
939 0 my $url = "$ro_url$file";
940 0 my($proto,$host,$dir,$getfile);
941  
942 # Courtesy Mark Conty mark_conty@cargill.com change from
943 # if ($url =~ m|^ftp://(.*?)/(.*)/(.*)|) {
944 # to
945 0 ▶ if ($url =~ m|^([^:]+)://(.*?)/(.*)/(.*)|) {
Branch: 2 branches
BranchTrueFalseTotal
if ($url =~ m[^([^:]+)://(.*?)/(.*)/(.*)]) { } 0 0 0
if ($url =~ m[^([^:]+)://(.*?)/(.*)/(.*)]) { } 0 0 0
946 # proto not yet used
947 0 ($proto,$host,$dir,$getfile) = ($1,$2,$3,$4);
948 } else {
949 0 next HOSTHARD; # who said, we could ftp anything except ftp?
950 }
951 0 ▶ next HOSTHARD if $proto eq "file"; # file URLs would have had
Branch: 2 branches
BranchTrueFalseTotal
if $proto eq "file" 0 0 0
if $proto eq "file" 0 0 0
952 # success above. Likely a bogus URL
953  
954 # making at least one attempt against a host
955 0 $any_attempt++;
956  
957 0 ▶ $self->debug("localizing funkyftpwise[$url]") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
958  
959 # Try the most capable first and leave ncftp* for last as it only
960 # does FTP.
961 0 my $proxy_vars = $self->_proxy_vars($ro_url);
962 0 DLPRG: for my $f (qw(curl wget lynx ncftpget ncftp)) {
963 0 my $funkyftp = CPAN::HandleConfig->safe_quote($CPAN::Config->{$f});
964 0 ▶ next DLPRG unless defined $funkyftp;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $funkyftp 0 0 0
unless defined $funkyftp 0 0 0
965 0 ▶ next DLPRG if $funkyftp =~ /^\s*$/;
Branch: 2 branches
BranchTrueFalseTotal
if $funkyftp =~ /^\s*$/ 0 0 0
if $funkyftp =~ /^\s*$/ 0 0 0
966  
967 0 my($src_switch) = "";
968 0 my($chdir) = "";
969 0 my($stdout_redir) = " > \"$aslocal\"";
970 0 ▶ if ($f eq "lynx") {
Branch: 10 branches
BranchTrueFalseTotal
if ($f eq 'lynx') { } 0 0 0
elsif ($f eq 'ncftp') { } 0 0 0
elsif ($f eq 'wget') { } 0 0 0
elsif ($f eq 'curl') { } 0 0 0
elsif ($f eq 'ncftpget') { } 0 0 0
if ($f eq 'lynx') { } 0 0 0
elsif ($f eq 'ncftp') { } 0 0 0
elsif ($f eq 'wget') { } 0 0 0
elsif ($f eq 'curl') { } 0 0 0
elsif ($f eq 'ncftpget') { } 0 0 0
971 0 $src_switch = " -source";
972 } elsif ($f eq "ncftp") {
973 0 ▶ next DLPRG unless $url =~ m{\Aftp://};
Branch: 2 branches
BranchTrueFalseTotal
unless $url =~ m[\Aftp://] 0 0 0
unless $url =~ m[\Aftp://] 0 0 0
974 0 $src_switch = " -c";
975 } elsif ($f eq "wget") {
976 0 $src_switch = " -O \"$aslocal\"";
977 0 $stdout_redir = "";
978 } elsif ($f eq 'curl') {
979 0 $src_switch = ' -L -f -s -S --netrc-optional';
980 0 ▶ if ($proxy_vars->{http_proxy}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($proxy_vars->{"http_proxy"}) 0 0 0
if ($proxy_vars->{"http_proxy"}) 0 0 0
981 0 $src_switch .= qq{ -U "$proxy_vars->{proxy_user}:$proxy_vars->{proxy_pass}" -x "$proxy_vars->{http_proxy}"};
982 }
983 } elsif ($f eq "ncftpget") {
984 0 ▶ next DLPRG unless $url =~ m{\Aftp://};
Branch: 2 branches
BranchTrueFalseTotal
unless $url =~ m[\Aftp://] 0 0 0
unless $url =~ m[\Aftp://] 0 0 0
985 0 $chdir = "cd $aslocal_dir && ";
986 0 $stdout_redir = "";
987 }
988 $CPAN::Frontend->myprint(
989 0 qq[
990 Trying with
991 $funkyftp$src_switch
992 to get
993 $url
994 ]);
995 0 my($system) =
996 "$chdir$funkyftp$src_switch \"$url\" $devnull$stdout_redir";
997 0 ▶ $self->debug("system[$system]") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
998 0 my($wstatus) = system($system);
999 0 ▶ if ($f eq "lynx") {
Branch: 2 branches
BranchTrueFalseTotal
if ($f eq "lynx") 0 0 0
if ($f eq "lynx") 0 0 0
1000 # lynx returns 0 when it fails somewhere
1001 0 ▶ if (-s $aslocal) {
Branch: 2 branches
BranchTrueFalseTotal
if (-s $aslocal) { } 0 0 0
if (-s $aslocal) { } 0 0 0
1002 0 my $content = do { local *FH;
1003 0 ▶ open FH, $aslocal or die;
Branch: 2 branches
BranchTrueFalseTotal
open FH, $aslocal or die 0 0 0
open FH, $aslocal or die 0 0 0
1004 0 local $/;
1005 0 <FH> };
1006 0 ▶ if ($content =~ /^<.*(<title>[45]|Error [45])/si) {
Branch: 2 branches
BranchTrueFalseTotal
if ($content =~ /^<.*(<title>[45]|Error [45])/is) 0 0 0
if ($content =~ /^<.*(<title>[45]|Error [45])/is) 0 0 0
1007 0 $CPAN::Frontend->mywarn(qq{
1008 No success, the file that lynx has downloaded looks like an error message:
1009 $content
1010 });
1011 0 $CPAN::Frontend->mysleep(1);
1012 0 next DLPRG;
1013 }
1014 0 $some_dl_success++;
1015 } else {
1016 0 $CPAN::Frontend->myprint(qq{
1017 No success, the file that lynx has downloaded is an empty file.
1018 });
1019 0 next DLPRG;
1020 }
1021 }
1022 0 ▶ if ($wstatus == 0) {
Branch: 2 branches
BranchTrueFalseTotal
if ($wstatus == 0) { } 0 0 0
if ($wstatus == 0) { } 0 0 0
1023 0 ▶ if (-s $aslocal) {
Branch: 2 branches
BranchTrueFalseTotal
if (-s $aslocal) 0 0 0
if (-s $aslocal) 0 0 0
1024 # Looks good
1025 0 $some_dl_success++;
1026 }
1027 0 $ThesiteURL = $ro_url;
1028 0 return $aslocal;
1029 } else {
1030 0 my $estatus = $wstatus >> 8;
1031 0 ▶ my $size = -f $aslocal ?
Branch: 2 branches
BranchTrueFalseTotal
-f $aslocal ? : 0 0 0
-f $aslocal ? : 0 0 0
1032 ", left\n$aslocal with size ".-s _ :
1033 "\nWarning: expected file [$aslocal] doesn't exist";
1034 0 $CPAN::Frontend->myprint(qq{
1035 Function system("$system")
1036 returned status $estatus (wstat $wstatus)$size
1037 });
1038 }
1039 0 ▶ return if $CPAN::Signal;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::Signal 0 0 0
if $CPAN::Signal 0 0 0
1040 } # download/transfer programs (DLPRG)
1041 } # host
1042 0 ▶ return unless $any_attempt;
Branch: 2 branches
BranchTrueFalseTotal
unless $any_attempt 0 0 0
unless $any_attempt 0 0 0
1043 0 ▶ if ($some_dl_success) {
Branch: 2 branches
BranchTrueFalseTotal
if ($some_dl_success) { } 0 0 0
if ($some_dl_success) { } 0 0 0
1044 0 $CPAN::Frontend->mywarn("Warning: doesn't seem we had substantial success downloading '$aslocal'. Don't know how to proceed.\n");
1045 } else {
1046 0 $CPAN::Frontend->mywarn("Warning: no success downloading '$aslocal'. Giving up on it.\n");
1047 }
1048 0 return;
1049 }
1050  
1051 #-> CPAN::FTP::_proxy_vars
1052 2 ▶sub _proxy_vars {
Subroutine _proxy_vars: called CC=9 SCAR=33.4
1053 0 ▶ my($self,$url) = @_;
Subroutine _proxy_vars: not called CC=9 SCAR=33.4
1054 0 my $ret = +{};
1055 0 ▶ my $http_proxy = $CPAN::Config->{'http_proxy'} || $ENV{'http_proxy'};
Condition16%1/6
$CPAN::Config->{'http_proxy'} || $ENV{'http_proxy'}
l!l&&r!l&&!r
200
$CPAN::Config->{'http_proxy'} || $ENV{'http_proxy'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$CPAN::Config->{'http_proxy'} || $ENV{'http_proxy'}
$CPAN::Config->{'http_proxy'} $ENV{'http_proxy'}
MC/DC0%0/2
$CPAN::Config->{'http_proxy'} || $ENV{'http_proxy'}
$CPAN::Config->{'http_proxy'} $ENV{'http_proxy'}
Truth table33%1/3
A || B
A= $CPAN::Config->{'http_proxy'}B= $ENV{'http_proxy'}
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $CPAN::Config->{'http_proxy'}B= $ENV{'http_proxy'}
ABresult
1X1
011
000
1056 0 ▶ if ($http_proxy) {
Branch: 2 branches
BranchTrueFalseTotal
if ($http_proxy) 2 0 2
if ($http_proxy) 0 0 0
1057 0 my($host) = $url =~ m|://([^/:]+)|;
1058 0 my $want_proxy = 1;
1059 0 ▶ my $noproxy = $CPAN::Config->{'no_proxy'} || $ENV{'no_proxy'} || "";
Condition20%2/10
$CPAN::Config->{'no_proxy'} || $ENV{'no_proxy'} || ''
l!l
20
$CPAN::Config->{"no_proxy"} or $ENV{"no_proxy"}
l!l&&r!l&&!r
200
$CPAN::Config->{'no_proxy'} || $ENV{'no_proxy'} || ''
l!l
00
$CPAN::Config->{"no_proxy"} or $ENV{"no_proxy"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$CPAN::Config->{'no_proxy'} || $ENV{'no_proxy'} || ''
$CPAN::Config->{"no_proxy"} $ENV{"no_proxy"}
MC/DC0%0/2
$CPAN::Config->{'no_proxy'} || $ENV{'no_proxy'} || ''
$CPAN::Config->{"no_proxy"} $ENV{"no_proxy"}
Truth table33%1/3
A or B
A= $CPAN::Config->{"no_proxy"}B= $ENV{"no_proxy"}
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $CPAN::Config->{"no_proxy"}B= $ENV{"no_proxy"}
ABresult
1X1
011
000
1060 0 my @noproxy = split /\s*,\s*/, $noproxy;
1061 0 ▶ if ($host) {
Branch: 2 branches
BranchTrueFalseTotal
if ($host) { } 2 0 2
if ($host) { } 0 0 0
1062 0 DOMAIN: for my $domain (@noproxy) {
1063 0 ▶ if ($host =~ /\Q$domain\E$/) { # cf. LWP::UserAgent
Branch: 2 branches
BranchTrueFalseTotal
if ($host =~ /\Q$domain\E$/) 1 1 2
if ($host =~ /\Q$domain\E$/) 0 0 0
1064 0 $want_proxy = 0;
1065 0 last DOMAIN;
1066 }
1067 }
1068 } else {
1069 0 $CPAN::Frontend->mywarn(" Could not determine host from http_proxy '$http_proxy'\n");
1070 }
1071 0 ▶ if ($want_proxy) {
Branch: 2 branches
BranchTrueFalseTotal
if ($want_proxy) 1 1 2
if ($want_proxy) 0 0 0
1072 0 my($user, $pass) =
1073 CPAN::HTTP::Credentials->get_proxy_credentials();
1074 0 $ret = {
1075 proxy_user => $user,
1076 proxy_pass => $pass,
1077 http_proxy => $http_proxy
1078 };
1079 }
1080 }
1081 0 return $ret;
1082 }
1083  
1084 # package CPAN::FTP;
1085 0 ▶sub hostdlhardest {
Subroutine hostdlhardest: not called CC=23 SCAR=63.1
Pod undocumented
1086 0 ▶ my($self,$host_seq,$file,$aslocal,$stats) = @_;
Subroutine hostdlhardest: not called CC=23 SCAR=63.1
Pod undocumented
1087  
1088 0 ▶ return unless @$host_seq;
Branch: 2 branches
BranchTrueFalseTotal
unless @$host_seq 0 0 0
unless @$host_seq 0 0 0
1089 0 my($ro_url);
1090 0 my($aslocal_dir) = dirname($aslocal);
1091 0 mkpath($aslocal_dir);
1092 0 my $ftpbin = $CPAN::Config->{ftp};
1093 0 ▶ unless ($ftpbin && length $ftpbin && MM->maybe_command($ftpbin)) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($ftpbin and length $ftpbin and "MM"->maybe_command($ftpbin)) 0 0 0
unless ($ftpbin and length $ftpbin and "MM"->maybe_command($ftpbin)) 0 0 0
Condition0%0/12
$ftpbin and length $ftpbin and "MM"->maybe_command($ftpbin)
!ll&&!rl&&r
000
$ftpbin and length $ftpbin
!ll&&!rl&&r
000
$ftpbin and length $ftpbin and "MM"->maybe_command($ftpbin)
!ll&&!rl&&r
000
$ftpbin and length $ftpbin
!ll&&!rl&&r
000
MC/DC0%0/3
$ftpbin and length $ftpbin and "MM"->maybe_command($ftpbin)
$ftpbin length $ftpbin "MM"->maybe_command($ftpbin)
MC/DC0%0/3
$ftpbin and length $ftpbin and "MM"->maybe_command($ftpbin)
$ftpbin length $ftpbin "MM"->maybe_command($ftpbin)
Truth table0%0/4
A and B and C
A= $ftpbinB= length $ftpbinC= "MM"->maybe_command($ftpbin)
ABCresult
0XX0
10X0
1100
1111
Truth table0%0/4
A and B and C
A= $ftpbinB= length $ftpbinC= "MM"->maybe_command($ftpbin)
ABCresult
0XX0
10X0
1100
1111
1094 0 $CPAN::Frontend->myprint("No external ftp command available\n\n");
1095 0 return;
1096 }
1097 0 $CPAN::Frontend->mywarn(qq{
1098 As a last resort we now switch to the external ftp command '$ftpbin'
1099 to get '$aslocal'.
1100  
1101 Doing so often leads to problems that are hard to diagnose.
1102  
1103 If you're the victim of such problems, please consider unsetting the
1104 ftp config variable with
1105  
1106 o conf ftp ""
1107 o conf commit
1108  
1109 });
1110 0 $CPAN::Frontend->mysleep(2);
1111 0 HOSTHARDEST: for $ro_url (@$host_seq) {
1112 0 $self->_set_attempt($stats,"dlhardest",$ro_url);
1113 0 my $url = "$ro_url$file";
1114 0 ▶ $self->debug("localizing ftpwise[$url]") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
1115 0 ▶ unless ($url =~ m|^ftp://(.*?)/(.*)/(.*)|) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($url =~ m[^ftp://(.*?)/(.*)/(.*)]) 0 0 0
unless ($url =~ m[^ftp://(.*?)/(.*)/(.*)]) 0 0 0
1116 0 next;
1117 }
1118 0 my($host,$dir,$getfile) = ($1,$2,$3);
1119 0 my $timestamp = 0;
1120 0 my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,
1121 $ctime,$blksize,$blocks) = stat($aslocal);
1122 0 ▶ $timestamp = $mtime ||= 0;
Condition0%0/4
$mtime ||= 0
l!l
00
$mtime ||= 0
l!l
00
MC/DC0%0/1
$mtime ||= 0
$mtime
MC/DC0%0/1
$mtime ||= 0
$mtime
Truth table0%0/2
A
A= $mtime
Aresult
11
00
Truth table0%0/2
A
A= $mtime
Aresult
11
00
1123 0 my($netrc) = CPAN::FTP::netrc->new;
1124 0 my($netrcfile) = $netrc->netrc;
1125 0 ▶ my($verbose) = $CPAN::DEBUG{'FTP'} & $CPAN::DEBUG ? " -v" : "";
Branch: 2 branches
BranchTrueFalseTotal
$CPAN::DEBUG{'FTP'} & $CPAN::DEBUG ? : 0 0 0
$CPAN::DEBUG{'FTP'} & $CPAN::DEBUG ? : 0 0 0
1126 0 my $targetfile = File::Basename::basename($aslocal);
1127 0 my(@dialog);
1128 0 push(
1129 @dialog,
1130 "lcd $aslocal_dir",
1131 "cd /",
1132 map("cd $_", split /\//, $dir), # RFC 1738
1133 "bin",
1134 "passive",
1135 "get $getfile $targetfile",
1136 "quit"
1137 );
1138 0 ▶ if (! $netrcfile) {
Branch: 4 branches
BranchTrueFalseTotal
if (not $netrcfile) { } 0 0 0
elsif ($netrc->hasdefault or $netrc->contains($host)) { } 0 0 0
if (not $netrcfile) { } 0 0 0
elsif ($netrc->hasdefault or $netrc->contains($host)) { } 0 0 0
1139 0 ▶ CPAN->debug("No ~/.netrc file found") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
1140 ▶ } elsif ($netrc->hasdefault || $netrc->contains($host)) {
Condition0%0/6
$netrc->hasdefault or $netrc->contains($host)
l!l&&r!l&&!r
000
$netrc->hasdefault or $netrc->contains($host)
l!l&&r!l&&!r
000
MC/DC0%0/2
$netrc->hasdefault or $netrc->contains($host)
$netrc->hasdefault $netrc->contains($host)
MC/DC0%0/2
$netrc->hasdefault or $netrc->contains($host)
$netrc->hasdefault $netrc->contains($host)
Truth table0%0/3
A or B
A= $netrc->hasdefaultB= $netrc->contains($host)
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $netrc->hasdefaultB= $netrc->contains($host)
ABresult
1X1
011
000
1141 0 ▶ CPAN->debug(sprintf("hasdef[%d]cont($host)[%d]",
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
1142 $netrc->hasdefault,
1143 $netrc->contains($host))) if $CPAN::DEBUG;
1144 0 ▶ if ($netrc->protected) {
Branch: 2 branches
BranchTrueFalseTotal
if ($netrc->protected) { } 0 0 0
if ($netrc->protected) { } 0 0 0
1145 0 my $dialog = join "", map { " $_\n" } @dialog;
1146 0 my $netrc_explain;
1147 0 ▶ if ($netrc->contains($host)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($netrc->contains($host)) { } 0 0 0
if ($netrc->contains($host)) { } 0 0 0
1148 0 $netrc_explain = "Relying that your .netrc entry for '$host' ".
1149 "manages the login";
1150 } else {
1151 0 $netrc_explain = "Relying that your default .netrc entry ".
1152 "manages the login";
1153 }
1154 0 $CPAN::Frontend->myprint(qq{
1155 Trying with external ftp to get
1156 '$url'
1157 $netrc_explain
1158 Sending the dialog
1159 $dialog
1160 }
1161 );
1162 0 $self->talk_ftp("$ftpbin$verbose $host",
1163 @dialog);
1164 0 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
1165 $atime,$mtime,$ctime,$blksize,$blocks) = stat($aslocal);
1166 0 ▶ $mtime ||= 0;
Condition0%0/4
$mtime ||= 0
l!l
00
$mtime ||= 0
l!l
00
MC/DC0%0/1
$mtime ||= 0
$mtime
MC/DC0%0/1
$mtime ||= 0
$mtime
Truth table0%0/2
A
A= $mtime
Aresult
11
00
Truth table0%0/2
A
A= $mtime
Aresult
11
00
1167 0 ▶ if ($mtime > $timestamp) {
Branch: 2 branches
BranchTrueFalseTotal
if ($mtime > $timestamp) { } 0 0 0
if ($mtime > $timestamp) { } 0 0 0
1168 0 $CPAN::Frontend->myprint("GOT $aslocal\n");
1169 0 $ThesiteURL = $ro_url;
1170 0 return $aslocal;
1171 } else {
1172 0 $CPAN::Frontend->myprint("Hmm... Still failed!\n");
1173 }
1174 0 ▶ return if $CPAN::Signal;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::Signal 0 0 0
if $CPAN::Signal 0 0 0
1175 } else {
1176 0 $CPAN::Frontend->mywarn(qq{Your $netrcfile is not }.
1177 qq{correctly protected.\n});
1178 }
1179 } else {
1180 0 $CPAN::Frontend->mywarn("Your ~/.netrc neither contains $host
1181 nor does it have a default entry\n");
1182 }
1183  
1184 # OK, they don't have a valid ~/.netrc. Use 'ftp -n'
1185 # then and login manually to host, using e-mail as
1186 # password.
1187 0 $CPAN::Frontend->myprint(qq{Issuing "$ftpbin$verbose -n"\n});
1188 0 unshift(
1189 @dialog,
1190 "open $host",
1191 "user anonymous $Config::Config{'cf_email'}"
1192 );
1193 0 my $dialog = join "", map { " $_\n" } @dialog;
1194 0 $CPAN::Frontend->myprint(qq{
1195 Trying with external ftp to get
1196 $url
1197 Sending the dialog
1198 $dialog
1199 }
1200 );
1201 0 $self->talk_ftp("$ftpbin$verbose -n", @dialog);
1202 0 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
1203 $atime,$mtime,$ctime,$blksize,$blocks) = stat($aslocal);
1204 0 ▶ $mtime ||= 0;
Condition0%0/4
$mtime ||= 0
l!l
00
$mtime ||= 0
l!l
00
MC/DC0%0/1
$mtime ||= 0
$mtime
MC/DC0%0/1
$mtime ||= 0
$mtime
Truth table0%0/2
A
A= $mtime
Aresult
11
00
Truth table0%0/2
A
A= $mtime
Aresult
11
00
1205 0 ▶ if ($mtime > $timestamp) {
Branch: 2 branches
BranchTrueFalseTotal
if ($mtime > $timestamp) { } 0 0 0
if ($mtime > $timestamp) { } 0 0 0
1206 0 $CPAN::Frontend->myprint("GOT $aslocal\n");
1207 0 $ThesiteURL = $ro_url;
1208 0 return $aslocal;
1209 } else {
1210 0 $CPAN::Frontend->myprint("Bad luck... Still failed!\n");
1211 }
1212 0 ▶ return if $CPAN::Signal;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::Signal 0 0 0
if $CPAN::Signal 0 0 0
1213 0 $CPAN::Frontend->mywarn("Can't access URL $url.\n\n");
1214 0 $CPAN::Frontend->mysleep(2);
1215 } # host
1216 }
1217  
1218 # package CPAN::FTP;
1219 0 ▶sub talk_ftp {
Subroutine talk_ftp: not called CC=4 SCAR=30.0
Pod undocumented
1220 0 ▶ my($self,$command,@dialog) = @_;
Subroutine talk_ftp: not called CC=4 SCAR=30.0
Pod undocumented
1221 0 my $fh = FileHandle->new;
1222 0 ▶ $fh->open("|$command") or die "Couldn't open ftp: $!";
Branch: 2 branches
BranchTrueFalseTotal
$fh->open("|$command") or die "Couldn't open ftp: $!" 0 0 0
$fh->open("|$command") or die "Couldn't open ftp: $!" 0 0 0
1223 0 foreach (@dialog) { $fh->print("$_\n") }
1224 0 $fh->close; # Wait for process to complete
1225 0 my $wstatus = $?;
1226 0 my $estatus = $wstatus >> 8;
1227 0 ▶ $CPAN::Frontend->myprint(qq{
Branch: 2 branches
BranchTrueFalseTotal
if $wstatus 0 0 0
if $wstatus 0 0 0
1228 Subprocess "|$command"
1229 returned status $estatus (wstat $wstatus)
1230 }) if $wstatus;
1231 }
1232  
1233 # find2perl needs modularization, too, all the following is stolen
1234 # from there
1235 # CPAN::FTP::ls
1236 0 ▶sub ls {
Subroutine ls: not called CC=14 SCAR=53.5
Pod undocumented
1237 0 ▶ my($self,$name) = @_;
Subroutine ls: not called CC=14 SCAR=53.5
Pod undocumented
1238 0 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$sizemm,
1239 $atime,$mtime,$ctime,$blksize,$blocks) = lstat($name);
1240  
1241 0 my($perms,%user,%group);
1242 0 my $pname = $name;
1243  
1244 0 ▶ if ($blocks) {
Branch: 2 branches
BranchTrueFalseTotal
if ($blocks) { } 0 0 0
if ($blocks) { } 0 0 0
1245 0 $blocks = int(($blocks + 1) / 2);
1246 }
1247 else {
1248 0 $blocks = int(($sizemm + 1023) / 1024);
1249 }
1250  
1251 0 ▶ if (-f _) { $perms = '-'; }
Branch: 12 branches
BranchTrueFalseTotal
if (-f _) { } 0 0 0
elsif (-d _) { } 0 0 0
elsif (-c _) { } 0 0 0
elsif (-b _) { } 0 0 0
elsif (-p _) { } 0 0 0
elsif (-S _) { } 0 0 0
if (-f _) { } 0 0 0
elsif (-d _) { } 0 0 0
elsif (-c _) { } 0 0 0
elsif (-b _) { } 0 0 0
elsif (-p _) { } 0 0 0
elsif (-S _) { } 0 0 0
1252 0 elsif (-d _) { $perms = 'd'; }
1253 0 elsif (-c _) { $perms = 'c'; $sizemm = &sizemm; }
1254 0 elsif (-b _) { $perms = 'b'; $sizemm = &sizemm; }
1255 0 elsif (-p _) { $perms = 'p'; }
1256 0 elsif (-S _) { $perms = 's'; }
1257 0 else { $perms = 'l'; $pname .= ' -> ' . readlink($_); }
1258  
1259 0 my(@rwx) = ('---','--x','-w-','-wx','r--','r-x','rw-','rwx');
1260 0 my(@moname) = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
1261 0 my $tmpmode = $mode;
1262 0 my $tmp = $rwx[$tmpmode & 7];
1263 0 $tmpmode >>= 3;
1264 0 $tmp = $rwx[$tmpmode & 7] . $tmp;
1265 0 $tmpmode >>= 3;
1266 0 $tmp = $rwx[$tmpmode & 7] . $tmp;
1267 0 ▶ substr($tmp,2,1) =~ tr/-x/Ss/ if -u _;
Branch: 2 branches
BranchTrueFalseTotal
if -u _ 0 0 0
if -u _ 0 0 0
1268 0 ▶ substr($tmp,5,1) =~ tr/-x/Ss/ if -g _;
Branch: 2 branches
BranchTrueFalseTotal
if -g _ 0 0 0
if -g _ 0 0 0
1269 0 ▶ substr($tmp,8,1) =~ tr/-x/Tt/ if -k _;
Branch: 2 branches
BranchTrueFalseTotal
if -k _ 0 0 0
if -k _ 0 0 0
1270 0 $perms .= $tmp;
1271  
1272 0 ▶ my $user = $user{$uid} || $uid; # too lazy to implement lookup
Condition0%0/6
$user{$uid} || $uid
l!l&&r!l&&!r
000
$user{$uid} || $uid
l!l&&r!l&&!r
000
MC/DC0%0/2
$user{$uid} || $uid
$user{$uid} $uid
MC/DC0%0/2
$user{$uid} || $uid
$user{$uid} $uid
Truth table0%0/3
A || B
A= $user{$uid}B= $uid
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $user{$uid}B= $uid
ABresult
1X1
011
000
1273 0 ▶ my $group = $group{$gid} || $gid;
Condition0%0/6
$group{$gid} || $gid
l!l&&r!l&&!r
000
$group{$gid} || $gid
l!l&&r!l&&!r
000
MC/DC0%0/2
$group{$gid} || $gid
$group{$gid} $gid
MC/DC0%0/2
$group{$gid} || $gid
$group{$gid} $gid
Truth table0%0/3
A || B
A= $group{$gid}B= $gid
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $group{$gid}B= $gid
ABresult
1X1
011
000
1274  
1275 0 my($sec,$min,$hour,$mday,$mon,$year) = localtime($mtime);
1276 0 my($timeyear);
1277 0 my($moname) = $moname[$mon];
1278 0 ▶ if (-M _ > 365.25 / 2) {
Branch: 2 branches
BranchTrueFalseTotal
if (-M _ > 182.625) { } 0 0 0
if (-M _ > 182.625) { } 0 0 0
1279 0 $timeyear = $year + 1900;
1280 }
1281 else {
1282 0 $timeyear = sprintf("%02d:%02d", $hour, $min);
1283 }
1284  
1285 0 sprintf "%5lu %4ld %-10s %2d %-8s %-8s %8s %s %2d %5s %s\n",
1286 $ino,
1287 $blocks,
1288 $perms,
1289 $nlink,
1290 $user,
1291 $group,
1292 $sizemm,
1293 $moname,
1294 $mday,
1295 $timeyear,
1296 $pname;
1297 }
1298  
1299 26 1;
↑ Summary blib/lib/CPAN.pm »