blib/lib/CPAN/Index.pm

filter: Statementstmt 34.2% 222 / 649 Branchbran 25.7% 99 / 384 Conditioncond 13.7% 22 / 160 MC/DCmcdc 3.3% 3 / 90 Subroutinesub 47.8% 11 / 23 Podpod 0.0% 0 / 21 totaltotal 26.9% 357 / 1327 CC 271 SCAR 58.1
CC
271
Cov
29%
rd_modpacks
699.5
rd_modpacks
699.5
reanimate_build_dir
552.0
CRAP 335.0
« lib/CPAN/Admin.pm ↑ Summary blib/lib/CPAN/Module.pm »
1 package CPAN::Index;
2 26 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 26 ▶use vars qw($LAST_TIME $DATE_OF_02 $DATE_OF_03 $HAVE_REANIMATED $VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 26 $VERSION = "2.29";
5 26 @CPAN::Index::ISA = qw(CPAN::Debug);
6 26 ▶$LAST_TIME ||= 0;
Condition50%1/2
$CPAN::Index::LAST_TIME ||= 0
l!l
026
MC/DC0%0/1
$CPAN::Index::LAST_TIME ||= 0
$CPAN::Index::LAST_TIME
Truth table50%1/2
A
A= $CPAN::Index::LAST_TIME
Aresult
11
00
7 26 ▶$DATE_OF_03 ||= 0;
Condition50%1/2
$CPAN::Index::DATE_OF_03 ||= 0
l!l
026
MC/DC0%0/1
$CPAN::Index::DATE_OF_03 ||= 0
$CPAN::Index::DATE_OF_03
Truth table50%1/2
A
A= $CPAN::Index::DATE_OF_03
Aresult
11
00
8 # use constant PROTOCOL => "2.0"; # commented out to avoid warning on upgrade from 1.57
9 834 ▶sub PROTOCOL { 2.0 }
Subroutine PROTOCOL: called CC=1 SCAR=0.0
Pod undocumented
10  
11 #-> sub CPAN::Index::force_reload ;
12 0 ▶sub force_reload {
Subroutine force_reload: not called CC=1 SCAR=6.9
Pod undocumented
13 0 ▶ my($class) = @_;
Subroutine force_reload: not called CC=1 SCAR=6.9
Pod undocumented
14 0 $CPAN::Index::LAST_TIME = 0;
15 0 $class->reload(1);
16 }
17  
18 26 my @indexbundle =
19 (
20 {
21 reader => "rd_authindex",
22 dir => "authors",
23 remotefile => '01mailrc.txt.gz',
24 shortlocalfile => '01mailrc.gz',
25 },
26 {
27 reader => "rd_modpacks",
28 dir => "modules",
29 remotefile => '02packages.details.txt.gz',
30 shortlocalfile => '02packag.gz',
31 },
32 {
33 reader => "rd_modlist",
34 dir => "modules",
35 remotefile => '03modlist.data.gz',
36 shortlocalfile => '03mlist.gz',
37 },
38 );
39  
40 #-> sub CPAN::Index::reload ;
41 406 ▶sub reload {
Subroutine reload: called CC=18 SCAR=46.9
Pod undocumented
42 0 ▶ my($self,$force) = @_;
Subroutine reload: not called CC=18 SCAR=46.9
Pod undocumented
43 0 my $time = time;
44  
45 # XXX check if a newer one is available. (We currently read it
46 # from time to time)
47 0 for ($CPAN::Config->{index_expire}) {
48 0 ▶ $_ = 0.001 unless $_ && $_ > 0.001;
Branch: 2 branches
BranchTrueFalseTotal
unless $_ and $_ > "0.001" 0 406 406
unless $_ and $_ > "0.001" 0 0 0
Condition16%1/6
$_ and $_ > "0.001"
!ll&&!rl&&r
00406
$_ and $_ > "0.001"
!ll&&!rl&&r
000
MC/DC0%0/2
$_ and $_ > "0.001"
$_ $_ > "0.001"
MC/DC0%0/2
$_ and $_ > "0.001"
$_ $_ > "0.001"
Truth table33%1/3
A and B
A= $_B= $_ > "0.001"
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $_B= $_ > "0.001"
ABresult
0X0
100
111
49 }
50 0 unless (1 || $CPAN::Have_warned->{readmetadatacache}++) {
51 # debug here when CPAN doesn't seem to read the Metadata
52 require Carp;
53 Carp::cluck("META-PROTOCOL[$CPAN::META->{PROTOCOL}]");
54 }
55 0 ▶ unless ($CPAN::META->{PROTOCOL}) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($CPAN::META->{"PROTOCOL"}) 9 397 406
unless ($CPAN::META->{"PROTOCOL"}) 0 0 0
56 0 $self->read_metadata_cache;
57 0 ▶ $CPAN::META->{PROTOCOL} ||= "1.0";
Condition25%1/4
$CPAN::META->{"PROTOCOL"} ||= "1.0"
l!l
09
$CPAN::META->{"PROTOCOL"} ||= "1.0"
l!l
00
MC/DC0%0/1
$CPAN::META->{"PROTOCOL"} ||= "1.0"
$CPAN::META->{"PROTOCOL"}
MC/DC0%0/1
$CPAN::META->{"PROTOCOL"} ||= "1.0"
$CPAN::META->{"PROTOCOL"}
Truth table50%1/2
A
A= $CPAN::META->{"PROTOCOL"}
Aresult
11
00
Truth table0%0/2
A
A= $CPAN::META->{"PROTOCOL"}
Aresult
11
00
58 }
59 0 ▶ if ( $CPAN::META->{PROTOCOL} < PROTOCOL ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::META->{"PROTOCOL"} < PROTOCOL()) 9 397 406
if ($CPAN::META->{"PROTOCOL"} < PROTOCOL()) 0 0 0
60 # warn "Setting last_time to 0";
61 0 $LAST_TIME = 0; # No warning necessary
62 }
63 0 ▶ if ($LAST_TIME + $CPAN::Config->{index_expire}*86400 > $time
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::Index::LAST_TIME + $CPAN::Config->{'index_expire'} * 86400 > $time and not $force) { } 397 9 406
if ($CPAN::Index::LAST_TIME + $CPAN::Config->{'index_expire'} * 86400 > $time and not $force) { } 0 0 0
Condition33%2/6
$CPAN::Index::LAST_TIME + $CPAN::Config->{"index_expire"} * 86400 > $time and not $force
!ll&&!rl&&r
90397
$CPAN::Index::LAST_TIME + $CPAN::Config->{"index_expire"} * 86400 > $time and not $force
!ll&&!rl&&r
000
MC/DC50%1/2
$CPAN::Index::LAST_TIME + $CPAN::Config->{"index_expire"} * 86400 > $time and not $force
$CPAN::Index::LAST_TIME + $CPAN::Config->{"index_expire"} * 86400 > $time not $force
MC/DC0%0/2
$CPAN::Index::LAST_TIME + $CPAN::Config->{"index_expire"} * 86400 > $time and not $force
$CPAN::Index::LAST_TIME + $CPAN::Config->{"index_expire"} * 86400 > $time not $force
Truth table66%2/3
A and not(B)
A= $CPAN::Index::LAST_TIME + $CPAN::Config->{"index_expire"} * 86400 > $timeB= not $force
ABresult
0X0
100
111
Truth table0%0/3
A and not(B)
A= $CPAN::Index::LAST_TIME + $CPAN::Config->{"index_expire"} * 86400 > $timeB= not $force
ABresult
0X0
100
111
64 and ! $force) {
65 # called too often
66 # CPAN->debug("LAST_TIME[$LAST_TIME]index_expire[$CPAN::Config->{index_expire}]time[$time]");
67 } elsif (0) {
68 # IFF we are developing, it helps to wipe out the memory
69 # between reloads, otherwise it is not what a user expects.
70 undef $CPAN::META; # Neue Gruendlichkeit since v1.52(r1.274)
71 $CPAN::META = CPAN->new;
72 } else {
73 0 my($debug,$t2);
74 0 local $LAST_TIME = $time;
75 0 local $CPAN::META->{PROTOCOL} = PROTOCOL;
76  
77 0 my $needshort = $^O eq "dos";
78  
79 0 INX: for my $indexbundle (@indexbundle) {
80 0 my $reader = $indexbundle->{reader};
81 0 ▶ my $localfile = $needshort ? $indexbundle->{shortlocalfile} : $indexbundle->{remotefile};
Branch: 2 branches
BranchTrueFalseTotal
$needshort ? : 0 27 27
$needshort ? : 0 0 0
82 0 my $localpath = File::Spec->catfile($indexbundle->{dir}, $localfile);
83 0 my $remote = join "/", $indexbundle->{dir}, $indexbundle->{remotefile};
84 0 my $localized = $self->reload_x($remote, $localpath, $force);
85 0 $self->$reader($localized); # may die but we let the shell catch it
86 0 ▶ if ($CPAN::DEBUG){
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::DEBUG) 0 27 27
if ($CPAN::DEBUG) 0 0 0
87 0 $t2 = time;
88 0 $debug = "timing reading 01[".($t2 - $time)."]";
89 0 $time = $t2;
90 }
91 0 ▶ return if $CPAN::Signal; # this is sometimes lengthy
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::Signal 0 27 27
if $CPAN::Signal 0 0 0
92 }
93 0 $self->write_metadata_cache;
94 0 ▶ if ($CPAN::DEBUG){
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::DEBUG) 0 9 9
if ($CPAN::DEBUG) 0 0 0
95 0 $t2 = time;
96 0 $debug .= "03[".($t2 - $time)."]";
97 0 $time = $t2;
98 }
99 0 ▶ CPAN->debug($debug) if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 9 9
if $CPAN::DEBUG 0 0 0
100 }
101 0 ▶ if ($CPAN::Config->{build_dir_reuse}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::Config->{"build_dir_reuse"}) 0 406 406
if ($CPAN::Config->{"build_dir_reuse"}) 0 0 0
102 0 $self->reanimate_build_dir;
103 }
104 0 ▶ if (CPAN::_sqlite_running()) {
Branch: 2 branches
BranchTrueFalseTotal
if (CPAN::_sqlite_running()) 0 406 406
if (CPAN::_sqlite_running()) 0 0 0
105 0 ▶ $CPAN::SQLite->reload(time => $time, force => $force)
Branch: 2 branches
BranchTrueFalseTotal
unless $CPAN::Index::LAST_TIME 0 0 0
unless $CPAN::Index::LAST_TIME 0 0 0
106 if not $LAST_TIME;
107 }
108 0 $LAST_TIME = $time;
109 0 $CPAN::META->{PROTOCOL} = PROTOCOL;
110 }
111  
112 #-> sub CPAN::Index::reanimate_build_dir ;
113 0 ▶sub reanimate_build_dir {
Subroutine reanimate_build_dir: not called CC=23 SCAR=63.1
Pod undocumented
114 0 ▶ my($self) = @_;
Subroutine reanimate_build_dir: not called CC=23 SCAR=63.1
Pod undocumented
115 0 ▶ unless ($CPAN::META->has_inst($CPAN::Config->{yaml_module}||"YAML")) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($CPAN::META->has_inst($CPAN::Config->{"yaml_module"} || "YAML")) 0 0 0
unless ($CPAN::META->has_inst($CPAN::Config->{"yaml_module"} || "YAML")) 0 0 0
Condition0%0/4
$CPAN::Config->{'yaml_module'} || 'YAML'
l!l
00
$CPAN::Config->{'yaml_module'} || 'YAML'
l!l
00
MC/DC0%0/1
$CPAN::Config->{'yaml_module'} || 'YAML'
$CPAN::Config->{'yaml_module'}
MC/DC0%0/1
$CPAN::Config->{'yaml_module'} || 'YAML'
$CPAN::Config->{'yaml_module'}
Truth table0%0/2
A
A= $CPAN::Config->{'yaml_module'}
Aresult
11
00
Truth table0%0/2
A
A= $CPAN::Config->{'yaml_module'}
Aresult
11
00
116 0 return;
117 }
118 0 ▶ return if $HAVE_REANIMATED++;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::Index::HAVE_REANIMATED++ 0 0 0
if $CPAN::Index::HAVE_REANIMATED++ 0 0 0
119 0 my $d = $CPAN::Config->{build_dir};
120 0 my $dh = DirHandle->new;
121 0 ▶ opendir $dh, $d or return; # does not exist
Branch: 2 branches
BranchTrueFalseTotal
opendir $dh, $d or return 0 0 0
opendir $dh, $d or return 0 0 0
122 0 my $dirent;
123 0 my $i = 0;
124 0 my $painted = 0;
125 0 my $restored = 0;
126 0 my $start = CPAN::FTP::_mytime();
127 0 my @candidates = map { $_->[0] }
128 0 sort { $b->[1] <=> $a->[1] }
129 0 map { [ $_, -M File::Spec->catfile($d,$_) ] }
130 0 ▶ grep {/(.+)\.yml$/ && -d File::Spec->catfile($d,$1)} readdir $dh;
Condition0%0/6
/(.+)\.yml$/ && -d 'File::Spec'->catfile($d, $1)
!ll&&!rl&&r
000
/(.+)\.yml$/ && -d 'File::Spec'->catfile($d, $1)
!ll&&!rl&&r
000
MC/DC0%0/2
/(.+)\.yml$/ && -d 'File::Spec'->catfile($d, $1)
/(.+)\.yml$/ -d 'File::Spec'->catfile($d, $1)
MC/DC0%0/2
/(.+)\.yml$/ && -d 'File::Spec'->catfile($d, $1)
/(.+)\.yml$/ -d 'File::Spec'->catfile($d, $1)
Truth table0%0/3
A && B
A= /(.+)\.yml$/B= -d 'File::Spec'->catfile($d, $1)
ABresult
0X0
100
111
Truth table0%0/3
A && B
A= /(.+)\.yml$/B= -d 'File::Spec'->catfile($d, $1)
ABresult
0X0
100
111
131 0 ▶ if ( @candidates ) {
Branch: 2 branches
BranchTrueFalseTotal
if (@candidates) { } 0 0 0
if (@candidates) { } 0 0 0
132 $CPAN::Frontend->myprint
133 (sprintf("Reading %d yaml file%s from %s/\n",
134 scalar @candidates,
135 @candidates==1 ? "" : "s",
136 $CPAN::Config->{build_dir}
137 0 ▶ ));
Branch: 2 branches
BranchTrueFalseTotal
@candidates == 1 ? : 0 0 0
@candidates == 1 ? : 0 0 0
138 0 DISTRO: for $i (0..$#candidates) {
139 0 my $dirent = $candidates[$i];
140 0 my $y = eval {CPAN->_yaml_loadfile(File::Spec->catfile($d,$dirent), {loadblessed => 1})};
141 0 ▶ if ($@) {
Branch: 2 branches
BranchTrueFalseTotal
if ($@) 0 0 0
if ($@) 0 0 0
142 0 warn "Error while parsing file '$dirent'; error: '$@'";
143 0 next DISTRO;
144 }
145 0 my $c = $y->[0];
146 0 ▶ if ($c && $c->{perl} && $c->{distribution} && CPAN->_perl_fingerprint($c->{perl})) {
Branch: 2 branches
BranchTrueFalseTotal
if ($c and $c->{"perl"} and $c->{"distribution"} and "CPAN"->_perl_fingerprint($c->{"perl"})) 0 0 0
if ($c and $c->{"perl"} and $c->{"distribution"} and "CPAN"->_perl_fingerprint($c->{"perl"})) 0 0 0
Condition0%0/18
$c and $c->{"perl"} and $c->{"distribution"} and "CPAN"->_perl_fingerprint($c->{"perl"})
!ll&&!rl&&r
000
$c and $c->{"perl"} and $c->{"distribution"}
!ll&&!rl&&r
000
$c and $c->{"perl"}
!ll&&!rl&&r
000
$c and $c->{"perl"} and $c->{"distribution"} and "CPAN"->_perl_fingerprint($c->{"perl"})
!ll&&!rl&&r
000
$c and $c->{"perl"} and $c->{"distribution"}
!ll&&!rl&&r
000
$c and $c->{"perl"}
!ll&&!rl&&r
000
MC/DC0%0/4
$c and $c->{"perl"} and $c->{"distribution"} and "CPAN"->_perl_fingerprint($c->{"perl"})
$c $c->{"perl"} $c->{"distribution"} "CPAN"->_perl_fingerprint($c->{"perl"})
MC/DC0%0/4
$c and $c->{"perl"} and $c->{"distribution"} and "CPAN"->_perl_fingerprint($c->{"perl"})
$c $c->{"perl"} $c->{"distribution"} "CPAN"->_perl_fingerprint($c->{"perl"})
Truth table0%0/5
A and B and C and D
A= $cB= $c->{"perl"}C= $c->{"distribution"}D= "CPAN"->_perl_fingerprint($c->{"perl"})
ABCDresult
0XXX0
10XX0
110X0
11100
11111
Truth table0%0/5
A and B and C and D
A= $cB= $c->{"perl"}C= $c->{"distribution"}D= "CPAN"->_perl_fingerprint($c->{"perl"})
ABCDresult
0XXX0
10XX0
110X0
11100
11111
147 0 my $key = $c->{distribution}{ID};
148 0 for my $k (keys %{$c->{distribution}}) {
149 0 ▶ if ($c->{distribution}{$k}
Branch: 2 branches
BranchTrueFalseTotal
if ($c->{"distribution"}{$k} and ref $c->{"distribution"}{$k} and UNIVERSAL::isa($c->{"distribution"}{$k}, "CPAN::Distrostatus")) 0 0 0
if ($c->{"distribution"}{$k} and ref $c->{"distribution"}{$k} and UNIVERSAL::isa($c->{"distribution"}{$k}, "CPAN::Distrostatus")) 0 0 0
Condition0%0/12
$c->{"distribution"}{$k} and ref $c->{"distribution"}{$k} and UNIVERSAL::isa($c->{"distribution"}{$k}, "CPAN::Distrostatus")
!ll&&!rl&&r
000
$c->{"distribution"}{$k} and ref $c->{"distribution"}{$k}
!ll&&!rl&&r
000
$c->{"distribution"}{$k} and ref $c->{"distribution"}{$k} and UNIVERSAL::isa($c->{"distribution"}{$k}, "CPAN::Distrostatus")
!ll&&!rl&&r
000
$c->{"distribution"}{$k} and ref $c->{"distribution"}{$k}
!ll&&!rl&&r
000
MC/DC0%0/3
$c->{"distribution"}{$k} and ref $c->{"distribution"}{$k} and UNIVERSAL::isa($c->{"distribution"}{$k}, "CPAN::Distrostatus")
$c->{"distribution"}{$k} ref $c->{"distribution"}{$k} UNIVERSAL::isa($c->{"distribution"}{$k}, "CPAN::Distrostatus")
MC/DC0%0/3
$c->{"distribution"}{$k} and ref $c->{"distribution"}{$k} and UNIVERSAL::isa($c->{"distribution"}{$k}, "CPAN::Distrostatus")
$c->{"distribution"}{$k} ref $c->{"distribution"}{$k} UNIVERSAL::isa($c->{"distribution"}{$k}, "CPAN::Distrostatus")
Truth table0%0/4
A and B and C
A= $c->{"distribution"}{$k}B= ref $c->{"distribution"}{$k}C= UNIVERSAL::isa($c->{"distribution"}{$k}, "CPAN::Distrostatus")
ABCresult
0XX0
10X0
1100
1111
Truth table0%0/4
A and B and C
A= $c->{"distribution"}{$k}B= ref $c->{"distribution"}{$k}C= UNIVERSAL::isa($c->{"distribution"}{$k}, "CPAN::Distrostatus")
ABCresult
0XX0
10X0
1100
1111
150 && ref $c->{distribution}{$k}
151 && UNIVERSAL::isa($c->{distribution}{$k},"CPAN::Distrostatus")) {
152 0 $c->{distribution}{$k}{COMMANDID} = $i - @candidates;
153 }
154 }
155  
156 #we tried to restore only if element already
157 #exists; but then we do not work with metadata
158 #turned off.
159 my $do
160 = $CPAN::META->{readwrite}{'CPAN::Distribution'}{$key}
161 0 = $c->{distribution};
162 0 for my $skipper (qw(
163 badtestcnt
164 configure_requires_later
165 configure_requires_later_for
166 force_update
167 later
168 later_for
169 notest
170 should_report
171 sponsored_mods
172 prefs
173 negative_prefs_cache
174 )) {
175 0 delete $do->{$skipper};
176 }
177 0 ▶ if ($do->can("tested_ok_but_not_installed")) {
Branch: 2 branches
BranchTrueFalseTotal
if ($do->can("tested_ok_but_not_installed")) 0 0 0
if ($do->can("tested_ok_but_not_installed")) 0 0 0
178 0 ▶ if ($do->tested_ok_but_not_installed) {
Branch: 2 branches
BranchTrueFalseTotal
if ($do->tested_ok_but_not_installed) { } 0 0 0
if ($do->tested_ok_but_not_installed) { } 0 0 0
179 0 $CPAN::META->is_tested($do->{build_dir},$do->{make_test}{TIME});
180 } else {
181 0 next DISTRO;
182 }
183 }
184 0 $restored++;
185 }
186 0 $i++;
187 0 ▶ while (($painted/76) < ($i/@candidates)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($painted / 76 < $i / @candidates) 0 0 0
if ($painted / 76 < $i / @candidates) 0 0 0
188 0 $CPAN::Frontend->myprint(".");
189 0 $painted++;
190 }
191 }
192 }
193 else {
194 0 $CPAN::Frontend->myprint("Build_dir empty, nothing to restore\n");
195 }
196 0 my $took = CPAN::FTP::_mytime() - $start;
197 0 ▶ $CPAN::Frontend->myprint(sprintf(
Condition0%0/4
$restored || 'none'
l!l
00
$restored || 'none'
l!l
00
MC/DC0%0/1
$restored || 'none'
$restored
MC/DC0%0/1
$restored || 'none'
$restored
Truth table0%0/2
A
A= $restored
Aresult
11
00
Truth table0%0/2
A
A= $restored
Aresult
11
00
198 "DONE\nRestored the state of %s (in %.4f secs)\n",
199 $restored || "none",
200 $took,
201 ));
202 }
203  
204  
205 #-> sub CPAN::Index::reload_x ;
206 27 ▶sub reload_x {
Subroutine reload_x: called CC=6 SCAR=30.5
Pod undocumented
207 0 ▶ my($cl,$wanted,$localname,$force) = @_;
Subroutine reload_x: not called CC=6 SCAR=30.5
Pod undocumented
208 0 $force |= 2; # means we're dealing with an index here
209 0 CPAN::HandleConfig->load; # we should guarantee loading wherever
210 # we rely on Config XXX
211 0 ▶ $localname ||= $wanted;
Condition16%1/6
$localname ||= $wanted
l!l&&r!l&&!r
2700
$localname ||= $wanted
l!l&&r!l&&!r
000
MC/DC0%0/2
$localname ||= $wanted
$localname $wanted
MC/DC0%0/2
$localname ||= $wanted
$localname $wanted
Truth table33%1/3
A ||= B
A= $localnameB= $wanted
ABresult
1X1
011
000
Truth table0%0/3
A ||= B
A= $localnameB= $wanted
ABresult
1X1
011
000
212 0 my $abs_wanted = File::Spec->catfile($CPAN::Config->{'keep_source_where'},
213 $localname);
214 0 ▶ if (
Branch: 2 branches
BranchTrueFalseTotal
if (-f $abs_wanted and -M $abs_wanted < $CPAN::Config->{'index_expire'} and not $force & 1) { } 0 27 27
if (-f $abs_wanted and -M $abs_wanted < $CPAN::Config->{'index_expire'} and not $force & 1) { } 0 0 0
Condition16%2/12
-f $abs_wanted and -M $abs_wanted < $CPAN::Config->{"index_expire"} and not $force & 1
!ll&&!rl&&r
2700
-f $abs_wanted and -M $abs_wanted < $CPAN::Config->{"index_expire"}
!ll&&!rl&&r
2700
-f $abs_wanted and -M $abs_wanted < $CPAN::Config->{"index_expire"} and not $force & 1
!ll&&!rl&&r
000
-f $abs_wanted and -M $abs_wanted < $CPAN::Config->{"index_expire"}
!ll&&!rl&&r
000
MC/DC0%0/3
-f $abs_wanted and -M $abs_wanted < $CPAN::Config->{"index_expire"} and not $force & 1
-f $abs_wanted -M $abs_wanted < $CPAN::Config->{"index_expire"} not $force & 1
MC/DC0%0/3
-f $abs_wanted and -M $abs_wanted < $CPAN::Config->{"index_expire"} and not $force & 1
-f $abs_wanted -M $abs_wanted < $CPAN::Config->{"index_expire"} not $force & 1
Truth table25%1/4
A and B and not(C)
A= -f $abs_wantedB= -M $abs_wanted < $CPAN::Config->{"index_expire"}C= not $force & 1
ABCresult
0XX0
10X0
1100
1111
Truth table0%0/4
A and B and not(C)
A= -f $abs_wantedB= -M $abs_wanted < $CPAN::Config->{"index_expire"}C= not $force & 1
ABCresult
0XX0
10X0
1100
1111
215 -f $abs_wanted &&
216 -M $abs_wanted < $CPAN::Config->{'index_expire'} &&
217 !($force & 1)
218 ) {
219 0 ▶ my $s = $CPAN::Config->{'index_expire'} == 1 ? "" : "s";
Branch: 2 branches
BranchTrueFalseTotal
$CPAN::Config->{'index_expire'} == 1 ? : 0 0 0
$CPAN::Config->{'index_expire'} == 1 ? : 0 0 0
220 0 $cl->debug(qq{$abs_wanted younger than $CPAN::Config->{'index_expire'} }.
221 qq{day$s. I\'ll use that.});
222 0 return $abs_wanted;
223 } else {
224 0 $force |= 1; # means we're quite serious about it.
225 }
226 0 return CPAN::FTP->localize($wanted,$abs_wanted,$force);
227 }
228  
229 #-> sub CPAN::Index::rd_authindex ;
230 9 ▶sub rd_authindex {
Subroutine rd_authindex: called CC=12 SCAR=38.9
Pod undocumented
231 0 ▶ my($cl, $index_target) = @_;
Subroutine rd_authindex: not called CC=12 SCAR=38.9
Pod undocumented
232 0 ▶ return unless defined $index_target;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $index_target 0 9 9
unless defined $index_target 0 0 0
233 0 ▶ return if CPAN::_sqlite_running();
Branch: 2 branches
BranchTrueFalseTotal
if CPAN::_sqlite_running() 0 9 9
if CPAN::_sqlite_running() 0 0 0
234 0 my @lines;
235 0 $CPAN::Frontend->myprint("Reading '$index_target'\n");
236 0 local(*FH);
237 0 tie *FH, 'CPAN::Tarzip', $index_target;
238 0 local($/) = "\n";
239 0 local($_);
240 0 ▶ push @lines, split /\012/ while <FH>;
Branch: 2 branches
BranchTrueFalseTotal
defined($_ = readline FH) and do { push @lines, split(/\012/, $_, 0) } 11 9 20
defined($_ = readline FH) and do { push @lines, split(/\012/, $_, 0) } 0 0 0
241 0 my $i = 0;
242 0 my $painted = 0;
243 0 foreach (@lines) {
244 0 my($userid,$fullname,$email) =
245 m/alias\s+(\S+)\s+\"([^\"\<]*)\s+\<(.*)\>\"/;
246 0 ▶ $fullname ||= $email;
Condition16%1/6
$fullname ||= $email
l!l&&r!l&&!r
1100
$fullname ||= $email
l!l&&r!l&&!r
000
MC/DC0%0/2
$fullname ||= $email
$fullname $email
MC/DC0%0/2
$fullname ||= $email
$fullname $email
Truth table33%1/3
A ||= B
A= $fullnameB= $email
ABresult
1X1
011
000
Truth table0%0/3
A ||= B
A= $fullnameB= $email
ABresult
1X1
011
000
247 0 ▶ if ($userid && $fullname && $email) {
Branch: 2 branches
BranchTrueFalseTotal
if ($userid and $fullname and $email) { } 11 0 11
if ($userid and $fullname and $email) { } 0 0 0
Condition16%2/12
$userid and $fullname and $email
!ll&&!rl&&r
0011
$userid and $fullname
!ll&&!rl&&r
0011
$userid and $fullname and $email
!ll&&!rl&&r
000
$userid and $fullname
!ll&&!rl&&r
000
MC/DC0%0/3
$userid and $fullname and $email
$userid $fullname $email
MC/DC0%0/3
$userid and $fullname and $email
$userid $fullname $email
Truth table25%1/4
A and B and C
A= $useridB= $fullnameC= $email
ABCresult
0XX0
10X0
1100
1111
Truth table0%0/4
A and B and C
A= $useridB= $fullnameC= $email
ABCresult
0XX0
10X0
1100
1111
248 0 my $userobj = $CPAN::META->instance('CPAN::Author',$userid);
249 0 $userobj->set('FULLNAME' => $fullname, 'EMAIL' => $email);
250 } else {
251 0 ▶ CPAN->debug(sprintf "line[%s]", $_) if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 0 0
if $CPAN::DEBUG 0 0 0
252 }
253 0 $i++;
254 0 ▶ while (($painted/76) < ($i/@lines)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($painted / 76 < $i / @lines) 684 11 695
if ($painted / 76 < $i / @lines) 0 0 0
255 0 $CPAN::Frontend->myprint(".");
256 0 $painted++;
257 }
258 0 ▶ return if $CPAN::Signal;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::Signal 0 11 11
if $CPAN::Signal 0 0 0
259 }
260 0 $CPAN::Frontend->myprint("DONE\n");
261 }
262  
263 43 ▶sub userid {
Subroutine userid: called CC=2 SCAR=10.3
Pod undocumented
264 0 ▶ my($self,$dist) = @_;
Subroutine userid: not called CC=2 SCAR=10.3
Pod undocumented
265 0 ▶ $dist = $self->{'id'} unless defined $dist;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $dist 0 43 43
unless defined $dist 0 0 0
266 0 my($ret) = $dist =~ m|(?:\w/\w\w/)?([^/]+)/|;
267 0 $ret;
268 }
269  
270 #-> sub CPAN::Index::rd_modpacks ;
271 9 ▶sub rd_modpacks {
Subroutine rd_modpacks: called CC=43 SCAR=65.5
Pod undocumented
272 0 ▶ my($self, $index_target) = @_;
Subroutine rd_modpacks: not called CC=43 SCAR=65.5
Pod undocumented
273 0 ▶ return unless defined $index_target;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $index_target 0 9 9
unless defined $index_target 0 0 0
274 0 ▶ return if CPAN::_sqlite_running();
Branch: 2 branches
BranchTrueFalseTotal
if CPAN::_sqlite_running() 0 9 9
if CPAN::_sqlite_running() 0 0 0
275 0 $CPAN::Frontend->myprint("Reading '$index_target'\n");
276 0 my $fh = CPAN::Tarzip->TIEHANDLE($index_target);
277 0 local $_;
278 0 ▶ CPAN->debug(sprintf "start[%d]", time) if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 9 9
if $CPAN::DEBUG 0 0 0
279 0 my $slurp = "";
280 0 my $chunk;
281 0 ▶ while (my $bytes = $fh->READ(\$chunk,8192)) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $bytes = $fh->READ(\$chunk, 8192)) 9 9 18
if (my $bytes = $fh->READ(\$chunk, 8192)) 0 0 0
282 0 $slurp.=$chunk;
283 }
284 0 my @lines = split /\012/, $slurp;
285 0 ▶ CPAN->debug(sprintf "end[%d]", time) if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 9 9
if $CPAN::DEBUG 0 0 0
286 0 undef $fh;
287 # read header
288 0 my($line_count,$last_updated);
289 0 ▶ while (@lines) {
Branch: 2 branches
BranchTrueFalseTotal
if (@lines) 81 0 81
if (@lines) 0 0 0
290 0 my $shift = shift(@lines);
291 0 ▶ last if $shift =~ /^\s*$/;
Branch: 2 branches
BranchTrueFalseTotal
if $shift =~ /^\s*$/ 9 72 81
if $shift =~ /^\s*$/ 0 0 0
292 0 ▶ $shift =~ /^Line-Count:\s+(\d+)/ and $line_count = $1;
Branch: 2 branches
BranchTrueFalseTotal
$shift =~ /^Line-Count:\s+(\d+)/ and $line_count = $1 9 63 72
$shift =~ /^Line-Count:\s+(\d+)/ and $line_count = $1 0 0 0
293 0 ▶ $shift =~ /^Last-Updated:\s+(.+)/ and $last_updated = $1;
Branch: 2 branches
BranchTrueFalseTotal
$shift =~ /^Last-Updated:\s+(.+)/ and $last_updated = $1 9 63 72
$shift =~ /^Last-Updated:\s+(.+)/ and $last_updated = $1 0 0 0
294 }
295 0 ▶ CPAN->debug("line_count[$line_count]last_updated[$last_updated]") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 9 9
if $CPAN::DEBUG 0 0 0
296 0 my $errors = 0;
297 0 ▶ if (not defined $line_count) {
Branch: 4 branches
BranchTrueFalseTotal
if (not defined $line_count) { } 0 9 9
elsif ($line_count != scalar @lines) { } 0 9 9
if (not defined $line_count) { } 0 0 0
elsif ($line_count != scalar @lines) { } 0 0 0
298  
299 0 $CPAN::Frontend->mywarn(qq{Warning: Your $index_target does not contain a Line-Count header.
300 Please check the validity of the index file by comparing it to more
301 than one CPAN mirror. I'll continue but problems seem likely to
302 happen.\a
303 });
304 0 $errors++;
305 0 $CPAN::Frontend->mysleep(5);
306 } elsif ($line_count != scalar @lines) {
307  
308 0 $CPAN::Frontend->mywarn(sprintf qq{Warning: Your %s
309 contains a Line-Count header of %d but I see %d lines there. Please
310 check the validity of the index file by comparing it to more than one
311 CPAN mirror. I'll continue but problems seem likely to happen.\a\n},
312 $index_target, $line_count, scalar(@lines));
313  
314 }
315 0 ▶ if (not defined $last_updated) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $last_updated) { } 0 9 9
if (not defined $last_updated) { } 0 0 0
316  
317 0 $CPAN::Frontend->mywarn(qq{Warning: Your $index_target does not contain a Last-Updated header.
318 Please check the validity of the index file by comparing it to more
319 than one CPAN mirror. I'll continue but problems seem likely to
320 happen.\a
321 });
322 0 $errors++;
323 0 $CPAN::Frontend->mysleep(5);
324 } else {
325  
326 0 $CPAN::Frontend
327 ->myprint(sprintf qq{ Database was generated on %s\n},
328 $last_updated);
329 0 $DATE_OF_02 = $last_updated;
330  
331 0 my $age = time;
332 0 ▶ if ($CPAN::META->has_inst('HTTP::Date')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::META->has_inst('HTTP::Date')) { } 9 0 9
if ($CPAN::META->has_inst('HTTP::Date')) { } 0 0 0
333 0 require HTTP::Date;
334 0 $age -= HTTP::Date::str2time($last_updated);
335 } else {
336 0 $CPAN::Frontend->mywarn(" HTTP::Date not available\n");
337 0 require Time::Local;
338 0 my(@d) = $last_updated =~ / (\d+) (\w+) (\d+) (\d+):(\d+):(\d+) /;
339 0 $d[1] = index("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec", $d[1])/4;
340 0 ▶ $age -= $d[1]>=0 ? Time::Local::timegm(@d[5,4,3,0,1,2]) : 0;
Branch: 2 branches
BranchTrueFalseTotal
$d[1] >= 0 ? : 0 0 0
$d[1] >= 0 ? : 0 0 0
341 }
342 0 $age /= 3600*24;
343 0 ▶ if ($age > 30) {
Branch: 4 branches
BranchTrueFalseTotal
if ($age > 30) { } 9 0 9
elsif ($age < -1) { } 0 0 0
if ($age > 30) { } 0 0 0
elsif ($age < -1) { } 0 0 0
344  
345 0 $CPAN::Frontend
346 ->mywarn(sprintf
347 qq{Warning: This index file is %d days old.
348 Please check the host you chose as your CPAN mirror for staleness.
349 I'll continue but problems seem likely to happen.\a\n},
350 $age);
351  
352 } elsif ($age < -1) {
353  
354 0 $CPAN::Frontend
355 ->mywarn(sprintf
356 qq{Warning: Your system date is %d days behind this index file!
357 System time: %s
358 Timestamp index file: %s
359 Please fix your system time, problems with the make command expected.\n},
360 -$age,
361 scalar gmtime,
362 $DATE_OF_02,
363 );
364  
365 }
366 }
367  
368  
369 # A necessity since we have metadata_cache: delete what isn't
370 # there anymore
371 0 my $secondtime = $CPAN::META->exists("CPAN::Module","CPAN");
372 0 ▶ CPAN->debug("secondtime[$secondtime]") if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 9 9
if $CPAN::DEBUG 0 0 0
373 0 my(%exists);
374 0 my $i = 0;
375 0 my $painted = 0;
376 0 LINE: foreach (@lines) {
377 # before 1.56 we split into 3 and discarded the rest. From
378 # 1.57 we assign remaining text to $comment thus allowing to
379 # influence isa_perl
380 0 my($mod,$version,$dist,$comment) = split " ", $_, 4;
381 0 ▶ unless ($mod && defined $version && $dist) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($mod and defined $version and $dist) 0 73 73
unless ($mod and defined $version and $dist) 0 0 0
Condition16%2/12
$mod and defined $version and $dist
!ll&&!rl&&r
0073
$mod and defined $version
!ll&&!rl&&r
0073
$mod and defined $version and $dist
!ll&&!rl&&r
000
$mod and defined $version
!ll&&!rl&&r
000
MC/DC0%0/3
$mod and defined $version and $dist
$mod defined $version $dist
MC/DC0%0/3
$mod and defined $version and $dist
$mod defined $version $dist
Truth table25%1/4
A and B and C
A= $modB= defined $versionC= $dist
ABCresult
0XX0
10X0
1100
1111
Truth table0%0/4
A and B and C
A= $modB= defined $versionC= $dist
ABCresult
0XX0
10X0
1100
1111
382 0 require Dumpvalue;
383 0 my $dv = Dumpvalue->new(tick => '"');
384 0 $CPAN::Frontend->mywarn(sprintf "Could not split line[%s]\n", $dv->stringify($_));
385 0 ▶ if ($errors++ >= 5){
Branch: 2 branches
BranchTrueFalseTotal
if ($errors++ >= 5) 0 0 0
if ($errors++ >= 5) 0 0 0
386 0 $CPAN::Frontend->mydie("Giving up parsing your $index_target, too many errors");
387 }
388 0 next LINE;
389 }
390 0 my($bundle,$id,$userid);
391  
392 0 ▶ if ($mod eq 'CPAN' &&
Branch: 4 branches
BranchTrueFalseTotal
if ($mod eq 'CPAN' and not 'CPAN::Queue'->exists('Bundle::CPAN') || 'CPAN::Queue'->exists('CPAN')) { } 0 73 73
elsif ($mod =~ /^Bundle::(.*)/) { } 2 71 73
if ($mod eq 'CPAN' and not 'CPAN::Queue'->exists('Bundle::CPAN') || 'CPAN::Queue'->exists('CPAN')) { } 0 0 0
elsif ($mod =~ /^Bundle::(.*)/) { } 0 0 0
Condition8%1/12
$mod eq "CPAN" and not "CPAN::Queue"->exists("Bundle::CPAN") || "CPAN::Queue"->exists("CPAN")
!ll&&!rl&&r
7300
'CPAN::Queue'->exists('Bundle::CPAN') || 'CPAN::Queue'->exists('CPAN')
l!l&&r!l&&!r
000
$mod eq "CPAN" and not "CPAN::Queue"->exists("Bundle::CPAN") || "CPAN::Queue"->exists("CPAN")
!ll&&!rl&&r
000
'CPAN::Queue'->exists('Bundle::CPAN') || 'CPAN::Queue'->exists('CPAN')
l!l&&r!l&&!r
000
MC/DC0%0/3
$mod eq "CPAN" and not "CPAN::Queue"->exists("Bundle::CPAN") || "CPAN::Queue"->exists("CPAN")
$mod eq "CPAN" 'CPAN::Queue'->exists('Bundle::CPAN') 'CPAN::Queue'->exists('CPAN')
MC/DC0%0/3
$mod eq "CPAN" and not "CPAN::Queue"->exists("Bundle::CPAN") || "CPAN::Queue"->exists("CPAN")
$mod eq "CPAN" 'CPAN::Queue'->exists('Bundle::CPAN') 'CPAN::Queue'->exists('CPAN')
Truth table25%1/4
A and not(B || C)
A= $mod eq "CPAN"B= 'CPAN::Queue'->exists('Bundle::CPAN')C= 'CPAN::Queue'->exists('CPAN')
ABCresult
0XX0
11X0
1010
1001
Truth table0%0/4
A and not(B || C)
A= $mod eq "CPAN"B= 'CPAN::Queue'->exists('Bundle::CPAN')C= 'CPAN::Queue'->exists('CPAN')
ABCresult
0XX0
11X0
1010
1001
393 ! (
394 CPAN::Queue->exists('Bundle::CPAN') ||
395 CPAN::Queue->exists('CPAN')
396 )
397 ) {
398 0 local($^W)= 0;
399 0 ▶ if ($version > $CPAN::VERSION) {
Branch: 2 branches
BranchTrueFalseTotal
if ($version > $CPAN::VERSION) 0 0 0
if ($version > $CPAN::VERSION) 0 0 0
400 0 $CPAN::Frontend->mywarn(qq{
401 New CPAN.pm version (v$version) available.
402 [Currently running version is v$CPAN::VERSION]
403 You might want to try
404 install CPAN
405 reload cpan
406 to both upgrade CPAN.pm and run the new version without leaving
407 the current session.
408  
409 }); #});
410 0 $CPAN::Frontend->mysleep(2);
411 0 $CPAN::Frontend->myprint(qq{\n});
412 }
413 0 ▶ last if $CPAN::Signal;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::Signal 0 0 0
if $CPAN::Signal 0 0 0
414 } elsif ($mod =~ /^Bundle::(.*)/) {
415 0 $bundle = $1;
416 }
417  
418 0 ▶ if ($bundle) {
Branch: 2 branches
BranchTrueFalseTotal
if ($bundle) { } 2 71 73
if ($bundle) { } 0 0 0
419 0 $id = $CPAN::META->instance('CPAN::Bundle',$mod);
420 # Let's make it a module too, because bundles have so much
421 # in common with modules.
422  
423 # Changed in 1.57_63: seems like memory bloat now without
424 # any value, so commented out
425  
426 # $CPAN::META->instance('CPAN::Module',$mod);
427  
428 } else {
429  
430 # instantiate a module object
431 0 $id = $CPAN::META->instance('CPAN::Module',$mod);
432  
433 }
434  
435 # Although CPAN prohibits same name with different version the
436 # indexer may have changed the version for the same distro
437 # since the last time ("Force Reindexing" feature)
438 0 ▶ if ($id->cpan_file ne $dist
Branch: 2 branches
BranchTrueFalseTotal
if ($id->cpan_file ne $dist or $id->cpan_version ne $version) 43 30 73
if ($id->cpan_file ne $dist or $id->cpan_version ne $version) 0 0 0
Condition33%2/6
$id->cpan_file ne $dist or $id->cpan_version ne $version
l!l&&r!l&&!r
43030
$id->cpan_file ne $dist or $id->cpan_version ne $version
l!l&&r!l&&!r
000
MC/DC50%1/2
$id->cpan_file ne $dist or $id->cpan_version ne $version
$id->cpan_file ne $dist $id->cpan_version ne $version
MC/DC0%0/2
$id->cpan_file ne $dist or $id->cpan_version ne $version
$id->cpan_file ne $dist $id->cpan_version ne $version
Truth table66%2/3
A or B
A= $id->cpan_file ne $distB= $id->cpan_version ne $version
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $id->cpan_file ne $distB= $id->cpan_version ne $version
ABresult
1X1
011
000
439 ||
440 $id->cpan_version ne $version
441 ) {
442 0 ▶ $userid = $id->userid || $self->userid($dist);
Condition16%1/6
$id->userid || $self->userid($dist)
l!l&&r!l&&!r
0430
$id->userid || $self->userid($dist)
l!l&&r!l&&!r
000
MC/DC0%0/2
$id->userid || $self->userid($dist)
$id->userid $self->userid($dist)
MC/DC0%0/2
$id->userid || $self->userid($dist)
$id->userid $self->userid($dist)
Truth table33%1/3
A || B
A= $id->useridB= $self->userid($dist)
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $id->useridB= $self->userid($dist)
ABresult
1X1
011
000
443 0 $id->set(
444 'CPAN_USERID' => $userid,
445 'CPAN_VERSION' => $version,
446 'CPAN_FILE' => $dist,
447 );
448 }
449  
450 # instantiate a distribution object
451 0 ▶ if ($CPAN::META->exists('CPAN::Distribution',$dist)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::META->exists('CPAN::Distribution', $dist)) { } 32 41 73
if ($CPAN::META->exists('CPAN::Distribution', $dist)) { } 0 0 0
452 # we do not need CONTAINSMODS unless we do something with
453 # this dist, so we better produce it on demand.
454  
455 ## my $obj = $CPAN::META->instance(
456 ## 'CPAN::Distribution' => $dist
457 ## );
458 ## $obj->{CONTAINSMODS}{$mod} = undef; # experimental
459 } else {
460 0 $CPAN::META->instance(
461 'CPAN::Distribution' => $dist
462 )->set(
463 'CPAN_USERID' => $userid,
464 'CPAN_COMMENT' => $comment,
465 );
466 }
467 0 ▶ if ($secondtime) {
Branch: 2 branches
BranchTrueFalseTotal
if ($secondtime) 0 73 73
if ($secondtime) 0 0 0
468 0 for my $name ($mod,$dist) {
469 # $self->debug("exists name[$name]") if $CPAN::DEBUG;
470 0 $exists{$name} = undef;
471 }
472 }
473 0 $i++;
474 0 ▶ while (($painted/76) < ($i/@lines)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($painted / 76 < $i / @lines) 684 73 757
if ($painted / 76 < $i / @lines) 0 0 0
475 0 $CPAN::Frontend->myprint(".");
476 0 $painted++;
477 }
478 0 ▶ return if $CPAN::Signal;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::Signal 0 73 73
if $CPAN::Signal 0 0 0
479 }
480 0 $CPAN::Frontend->myprint("DONE\n");
481 0 ▶ if ($secondtime) {
Branch: 2 branches
BranchTrueFalseTotal
if ($secondtime) 0 9 9
if ($secondtime) 0 0 0
482 0 for my $class (qw(CPAN::Module CPAN::Bundle CPAN::Distribution)) {
483 0 for my $o ($CPAN::META->all_objects($class)) {
484 0 ▶ next if exists $exists{$o->{ID}};
Branch: 2 branches
BranchTrueFalseTotal
if exists $exists{$o->{"ID"}} 0 0 0
if exists $exists{$o->{"ID"}} 0 0 0
485 0 $CPAN::META->delete($class,$o->{ID});
486 # CPAN->debug("deleting ID[$o->{ID}] in class[$class]")
487 # if $CPAN::DEBUG;
488 }
489 }
490 }
491 }
492  
493 #-> sub CPAN::Index::rd_modlist ;
494 9 ▶sub rd_modlist {
Subroutine rd_modlist: called CC=15 SCAR=40.8
Pod undocumented
495 0 ▶ my($cl,$index_target) = @_;
Subroutine rd_modlist: not called CC=15 SCAR=40.8
Pod undocumented
496 0 ▶ return unless defined $index_target;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $index_target 0 9 9
unless defined $index_target 0 0 0
497 0 ▶ return if CPAN::_sqlite_running();
Branch: 2 branches
BranchTrueFalseTotal
if CPAN::_sqlite_running() 0 9 9
if CPAN::_sqlite_running() 0 0 0
498 0 $CPAN::Frontend->myprint("Reading '$index_target'\n");
499 0 my $fh = CPAN::Tarzip->TIEHANDLE($index_target);
500 0 local $_;
501 0 my $slurp = "";
502 0 my $chunk;
503 0 ▶ while (my $bytes = $fh->READ(\$chunk,8192)) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $bytes = $fh->READ(\$chunk, 8192)) 9 9 18
if (my $bytes = $fh->READ(\$chunk, 8192)) 0 0 0
504 0 $slurp.=$chunk;
505 }
506 0 my @eval2 = split /\012/, $slurp;
507  
508 0 ▶ while (@eval2) {
Branch: 2 branches
BranchTrueFalseTotal
if (@eval2) 72 0 72
if (@eval2) 0 0 0
509 0 my $shift = shift(@eval2);
510 0 ▶ if ($shift =~ /^Date:\s+(.*)/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($shift =~ /^Date:\s+(.*)/) 7 65 72
if ($shift =~ /^Date:\s+(.*)/) 0 0 0
511 0 ▶ if ($DATE_OF_03 eq $1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($CPAN::Index::DATE_OF_03 eq $1) 0 7 7
if ($CPAN::Index::DATE_OF_03 eq $1) 0 0 0
512 0 $CPAN::Frontend->myprint("Unchanged.\n");
513 0 return;
514 }
515 0 ($DATE_OF_03) = $1;
516 }
517 0 ▶ last if $shift =~ /^\s*$/;
Branch: 2 branches
BranchTrueFalseTotal
if $shift =~ /^\s*$/ 9 63 72
if $shift =~ /^\s*$/ 0 0 0
518 }
519 0 push @eval2, q{CPAN::Modulelist->data;};
520 0 local($^W) = 0;
521 0 my($compmt) = Safe->new("CPAN::Safe1");
522 0 my($eval2) = join("\n", @eval2);
523 0 ▶ CPAN->debug(sprintf "length of eval2[%d]", length $eval2) if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 9 9
if $CPAN::DEBUG 0 0 0
524 0 my $ret = $compmt->reval($eval2);
525 0 ▶ Carp::confess($@) if $@;
Branch: 2 branches
BranchTrueFalseTotal
if $@ 0 9 9
if $@ 0 0 0
526 0 ▶ return if $CPAN::Signal;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::Signal 0 9 9
if $CPAN::Signal 0 0 0
527 0 my $i = 0;
528 0 my $until = keys(%$ret);
529 0 my $painted = 0;
530 0 ▶ CPAN->debug(sprintf "until[%d]", $until) if $CPAN::DEBUG;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::DEBUG 0 9 9
if $CPAN::DEBUG 0 0 0
531 0 for (sort keys %$ret) {
532 0 my $obj = $CPAN::META->instance("CPAN::Module",$_);
533 0 delete $ret->{$_}{modid}; # not needed here, maybe elsewhere
534 0 $obj->set(%{$ret->{$_}});
535 0 $i++;
536 0 ▶ while (($painted/76) < ($i/$until)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($painted / 76 < $i / $until) 152 6 158
if ($painted / 76 < $i / $until) 0 0 0
537 0 $CPAN::Frontend->myprint(".");
538 0 $painted++;
539 }
540 0 ▶ return if $CPAN::Signal;
Branch: 2 branches
BranchTrueFalseTotal
if $CPAN::Signal 0 6 6
if $CPAN::Signal 0 0 0
541 }
542 0 $CPAN::Frontend->myprint("DONE\n");
543 }
544  
545 #-> sub CPAN::Index::write_metadata_cache ;
546 9 ▶sub write_metadata_cache {
Subroutine write_metadata_cache: called CC=6 SCAR=25.3
Pod undocumented
547 0 ▶ my($self) = @_;
Subroutine write_metadata_cache: not called CC=6 SCAR=25.3
Pod undocumented
548 0 ▶ return unless $CPAN::Config->{'cache_metadata'};
Branch: 2 branches
BranchTrueFalseTotal
unless $CPAN::Config->{"cache_metadata"} 2 7 9
unless $CPAN::Config->{"cache_metadata"} 0 0 0
549 0 ▶ return if CPAN::_sqlite_running();
Branch: 2 branches
BranchTrueFalseTotal
if CPAN::_sqlite_running() 0 7 7
if CPAN::_sqlite_running() 0 0 0
550 0 ▶ return unless $CPAN::META->has_usable("Storable");
Branch: 2 branches
BranchTrueFalseTotal
unless $CPAN::META->has_usable("Storable") 0 7 7
unless $CPAN::META->has_usable("Storable") 0 0 0
551 0 my $cache;
552 0 foreach my $k (qw(CPAN::Bundle CPAN::Author CPAN::Module
553 CPAN::Distribution)) {
554 0 $cache->{$k} = $CPAN::META->{readonly}{$k}; # unsafe meta access, ok
555 }
556 0 my $metadata_file = File::Spec->catfile($CPAN::Config->{cpan_home},"Metadata");
557 0 $cache->{last_time} = $LAST_TIME;
558 0 $cache->{DATE_OF_02} = $DATE_OF_02;
559 0 $cache->{PROTOCOL} = PROTOCOL;
560 0 $CPAN::Frontend->myprint("Writing $metadata_file\n");
561 0 eval { Storable::nstore($cache, $metadata_file) };
562 0 ▶ $CPAN::Frontend->mywarn($@) if $@; # ?? missing "\n" after $@ in mywarn ??
Branch: 2 branches
BranchTrueFalseTotal
if $@ 0 7 7
if $@ 0 0 0
563 }
564  
565 #-> sub CPAN::Index::read_metadata_cache ;
566 9 ▶sub read_metadata_cache {
Subroutine read_metadata_cache: called CC=19 SCAR=49.4
Pod undocumented
567 0 ▶ my($self) = @_;
Subroutine read_metadata_cache: not called CC=19 SCAR=49.4
Pod undocumented
568 0 ▶ return unless $CPAN::Config->{'cache_metadata'};
Branch: 2 branches
BranchTrueFalseTotal
unless $CPAN::Config->{"cache_metadata"} 2 7 9
unless $CPAN::Config->{"cache_metadata"} 0 0 0
569 0 ▶ return if CPAN::_sqlite_running();
Branch: 2 branches
BranchTrueFalseTotal
if CPAN::_sqlite_running() 0 7 7
if CPAN::_sqlite_running() 0 0 0
570 0 ▶ return unless $CPAN::META->has_usable("Storable");
Branch: 2 branches
BranchTrueFalseTotal
unless $CPAN::META->has_usable("Storable") 0 7 7
unless $CPAN::META->has_usable("Storable") 0 0 0
571 0 my $metadata_file = File::Spec->catfile($CPAN::Config->{cpan_home},"Metadata");
572 0 ▶ return unless -r $metadata_file and -f $metadata_file;
Branch: 2 branches
BranchTrueFalseTotal
unless -r $metadata_file and -f $metadata_file 1 6 7
unless -r $metadata_file and -f $metadata_file 0 0 0
Condition33%2/6
-r $metadata_file and -f $metadata_file
!ll&&!rl&&r
106
-r $metadata_file and -f $metadata_file
!ll&&!rl&&r
000
MC/DC50%1/2
-r $metadata_file and -f $metadata_file
-r $metadata_file -f $metadata_file
MC/DC0%0/2
-r $metadata_file and -f $metadata_file
-r $metadata_file -f $metadata_file
Truth table66%2/3
A and B
A= -r $metadata_fileB= -f $metadata_file
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= -r $metadata_fileB= -f $metadata_file
ABresult
0X0
100
111
573 0 $CPAN::Frontend->myprint("Reading '$metadata_file'\n");
574 0 my $cache;
575 0 eval { $cache = Storable::retrieve($metadata_file) };
576 0 ▶ $CPAN::Frontend->mywarn($@) if $@; # ?? missing "\n" after $@ in mywarn ??
Branch: 2 branches
BranchTrueFalseTotal
if $@ 0 6 6
if $@ 0 0 0
577 0 ▶ if (!$cache || !UNIVERSAL::isa($cache, 'HASH')) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($cache and UNIVERSAL::isa($cache, "HASH")) 0 6 6
unless ($cache and UNIVERSAL::isa($cache, "HASH")) 0 0 0
Condition16%1/6
$cache and UNIVERSAL::isa($cache, "HASH")
!ll&&!rl&&r
006
$cache and UNIVERSAL::isa($cache, "HASH")
!ll&&!rl&&r
000
MC/DC0%0/2
$cache and UNIVERSAL::isa($cache, "HASH")
$cache UNIVERSAL::isa($cache, "HASH")
MC/DC0%0/2
$cache and UNIVERSAL::isa($cache, "HASH")
$cache UNIVERSAL::isa($cache, "HASH")
Truth table33%1/3
A and B
A= $cacheB= UNIVERSAL::isa($cache, "HASH")
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $cacheB= UNIVERSAL::isa($cache, "HASH")
ABresult
0X0
100
111
578 0 $LAST_TIME = 0;
579 0 return;
580 }
581 0 ▶ if (exists $cache->{PROTOCOL}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $cache->{'PROTOCOL'}) { } 6 0 6
if (exists $cache->{'PROTOCOL'}) { } 0 0 0
582 0 ▶ if (PROTOCOL > $cache->{PROTOCOL}) {
Branch: 2 branches
BranchTrueFalseTotal
if (PROTOCOL() > $cache->{"PROTOCOL"}) 0 6 6
if (PROTOCOL() > $cache->{"PROTOCOL"}) 0 0 0
583 $CPAN::Frontend->mywarn(sprintf("Ignoring Metadata cache written ".
584 "with protocol v%s, requiring v%s\n",
585 $cache->{PROTOCOL},
586 0 PROTOCOL)
587 );
588 0 return;
589 }
590 } else {
591 0 $CPAN::Frontend->mywarn("Ignoring Metadata cache written ".
592 "with protocol v1.0\n");
593 0 return;
594 }
595 0 my $clcnt = 0;
596 0 my $idcnt = 0;
597 0 ▶ while(my($class,$v) = each %$cache) {
Branch: 2 branches
BranchTrueFalseTotal
if (() = each %$cache) 42 6 48
if (() = each %$cache) 0 0 0
598 0 ▶ next unless $class =~ /^CPAN::/;
Branch: 2 branches
BranchTrueFalseTotal
unless $class =~ /^CPAN::/ 18 24 42
unless $class =~ /^CPAN::/ 0 0 0
599 0 $CPAN::META->{readonly}{$class} = $v; # unsafe meta access, ok
600 0 ▶ while (my($id,$ro) = each %$v) {
Branch: 2 branches
BranchTrueFalseTotal
if (() = each %$v) 66 24 90
if (() = each %$v) 0 0 0
601 0 ▶ $CPAN::META->{readwrite}{$class}{$id} ||=
Condition16%1/6
$CPAN::META->{"readwrite"}{$class}{$id} ||= $class->new("ID", $id, "RO", $ro)
l!l&&r!l&&!r
0660
$CPAN::META->{"readwrite"}{$class}{$id} ||= $class->new("ID", $id, "RO", $ro)
l!l&&r!l&&!r
000
MC/DC0%0/2
$CPAN::META->{"readwrite"}{$class}{$id} ||= $class->new("ID", $id, "RO", $ro)
$CPAN::META->{"readwrite"}{$class}{$id} $class->new("ID", $id, "RO", $ro)
MC/DC0%0/2
$CPAN::META->{"readwrite"}{$class}{$id} ||= $class->new("ID", $id, "RO", $ro)
$CPAN::META->{"readwrite"}{$class}{$id} $class->new("ID", $id, "RO", $ro)
Truth table33%1/3
A ||= B
A= $CPAN::META->{"readwrite"}{$class}{$id}B= $class->new("ID", $id, "RO", $ro)
ABresult
1X1
011
000
Truth table0%0/3
A ||= B
A= $CPAN::META->{"readwrite"}{$class}{$id}B= $class->new("ID", $id, "RO", $ro)
ABresult
1X1
011
000
602 $class->new(ID=>$id, RO=>$ro);
603 0 $idcnt++;
604 }
605 0 $clcnt++;
606 }
607 0 ▶ unless ($clcnt) { # sanity check
Branch: 2 branches
BranchTrueFalseTotal
unless ($clcnt) 0 6 6
unless ($clcnt) 0 0 0
608 0 $CPAN::Frontend->myprint("Warning: Found no data in $metadata_file\n");
609 0 return;
610 }
611 0 ▶ if ($idcnt < 1000) {
Branch: 2 branches
BranchTrueFalseTotal
if ($idcnt < 1000) 6 0 6
if ($idcnt < 1000) 0 0 0
612 0 $CPAN::Frontend->myprint("Warning: Found only $idcnt objects ".
613 "in $metadata_file\n");
614 0 return;
615 }
616 $CPAN::META->{PROTOCOL} ||=
617 0 ▶ $cache->{PROTOCOL}; # reading does not up or downgrade, but it
Condition0%0/6
$CPAN::META->{"PROTOCOL"} ||= $cache->{"PROTOCOL"}
l!l&&r!l&&!r
000
$CPAN::META->{"PROTOCOL"} ||= $cache->{"PROTOCOL"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$CPAN::META->{"PROTOCOL"} ||= $cache->{"PROTOCOL"}
$CPAN::META->{"PROTOCOL"} $cache->{"PROTOCOL"}
MC/DC0%0/2
$CPAN::META->{"PROTOCOL"} ||= $cache->{"PROTOCOL"}
$CPAN::META->{"PROTOCOL"} $cache->{"PROTOCOL"}
Truth table0%0/3
A ||= B
A= $CPAN::META->{"PROTOCOL"}B= $cache->{"PROTOCOL"}
ABresult
1X1
011
000
Truth table0%0/3
A ||= B
A= $CPAN::META->{"PROTOCOL"}B= $cache->{"PROTOCOL"}
ABresult
1X1
011
000
618 # does initialize to some protocol
619 0 $LAST_TIME = $cache->{last_time};
620 0 $DATE_OF_02 = $cache->{DATE_OF_02};
621 0 ▶ $CPAN::Frontend->myprint(" Database was generated on $DATE_OF_02\n")
Branch: 2 branches
BranchTrueFalseTotal
if defined $CPAN::Index::DATE_OF_02 0 0 0
if defined $CPAN::Index::DATE_OF_02 0 0 0
622 if defined $DATE_OF_02; # An old cache may not contain DATE_OF_02
623 0 return;
624 }
625  
626 26 1;
« lib/CPAN/Admin.pm ↑ Summary blib/lib/CPAN/Module.pm »