| 1 | # -*- Mode: cperl; coding: utf-8; cperl-indent-level: 4 -*- | ||||||||||||||||||||||||||||
| 2 | # vim: ts=4 sts=4 sw=4: | ||||||||||||||||||||||||||||
| 3 | package CPAN::CacheMgr; | ||||||||||||||||||||||||||||
| 4 | 24 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 24 | ▶ | use CPAN::InfoObj; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 24 | @CPAN::CacheMgr::ISA = qw(CPAN::InfoObj CPAN); | |||||||||||||||||||||||||||
| 7 | 24 | ▶ | use Cwd qw(chdir); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 24 | ▶ | use File::Find; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 24 | use vars qw( | |||||||||||||||||||||||||||
| 11 | $VERSION | ||||||||||||||||||||||||||||
| 12 | 24 | ▶ | ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 24 | $VERSION = "5.5003"; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | package CPAN::CacheMgr; | ||||||||||||||||||||||||||||
| 16 | 24 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | #-> sub CPAN::CacheMgr::as_string ; | ||||||||||||||||||||||||||||
| 19 | sub as_string { | ||||||||||||||||||||||||||||
| 20 | 0 | ▶ | eval { require Data::Dumper }; | ||||||||||||||||||||||||||
|
Subroutine
as_string: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 21 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 0 | return shift->SUPER::as_string; | |||||||||||||||||||||||||||
| 23 | } else { | ||||||||||||||||||||||||||||
| 24 | 0 | return Data::Dumper::Dumper(shift); | |||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | #-> sub CPAN::CacheMgr::cachesize ; | ||||||||||||||||||||||||||||
| 29 | sub cachesize { | ||||||||||||||||||||||||||||
| 30 | 0 | ▶ | shift->{DU}; | ||||||||||||||||||||||||||
|
Subroutine
cachesize: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | #-> sub CPAN::CacheMgr::tidyup ; | ||||||||||||||||||||||||||||
| 34 | sub tidyup { | ||||||||||||||||||||||||||||
| 35 | 0 | ▶ | my($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
tidyup: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | return unless $CPAN::META->{LOCK}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | return unless -d $self->{ID}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 0 | my @toremove = grep { $self->{SIZE}{$_}==0 } @{$self->{FIFO}}; | |||||||||||||||||||||||||||
| 39 | 0 | for my $current (0..$#toremove) { | |||||||||||||||||||||||||||
| 40 | 0 | my $toremove = $toremove[$current]; | |||||||||||||||||||||||||||
| 41 | 0 | $CPAN::Frontend->myprint(sprintf( | |||||||||||||||||||||||||||
| 42 | "DEL(%d/%d): %s \n", | ||||||||||||||||||||||||||||
| 43 | $current+1, | ||||||||||||||||||||||||||||
| 44 | scalar @toremove, | ||||||||||||||||||||||||||||
| 45 | $toremove, | ||||||||||||||||||||||||||||
| 46 | ) | ||||||||||||||||||||||||||||
| 47 | ); | ||||||||||||||||||||||||||||
| 48 | 0 | ▶ | return if $CPAN::Signal; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 0 | $self->_clean_cache($toremove); | |||||||||||||||||||||||||||
| 50 | 0 | ▶ | return if $CPAN::Signal; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | 0 | $self->{FIFO} = []; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | #-> sub CPAN::CacheMgr::dir ; | ||||||||||||||||||||||||||||
| 56 | sub dir { | ||||||||||||||||||||||||||||
| 57 | 7 | ▶ | shift->{ID}; | ||||||||||||||||||||||||||
|
Subroutine
dir: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | #-> sub CPAN::CacheMgr::entries ; | ||||||||||||||||||||||||||||
| 61 | sub entries { | ||||||||||||||||||||||||||||
| 62 | 0 | ▶ | my($self,$dir) = @_; | ||||||||||||||||||||||||||
|
Subroutine
entries: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 63 | 0 | ▶ | return unless defined $dir; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 0 | ▶ | $self->debug("reading dir[$dir]") if $CPAN::DEBUG; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 0 | ▶ | $dir ||= $self->{ID}; | ||||||||||||||||||||||||||
|
Condition0%0/3
$dir ||= $self->{"ID"}
MC/DC0%0/2
$dir ||= $self->{"ID"}
$dir
$self->{"ID"}
Truth table0%0/3
A ||= B
A= $dirB= $self->{"ID"}
| |||||||||||||||||||||||||||||
| 66 | 0 | my($cwd) = CPAN::anycwd(); | |||||||||||||||||||||||||||
| 67 | 0 | ▶ | chdir $dir or Carp::croak("Can't chdir to $dir: $!"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | my $dh = DirHandle->new(File::Spec->curdir) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | or Carp::croak("Couldn't opendir $dir: $!"); | ||||||||||||||||||||||||||||
| 70 | 0 | my(@entries); | |||||||||||||||||||||||||||
| 71 | 0 | for ($dh->read) { | |||||||||||||||||||||||||||
| 72 | 0 | ▶ | next if $_ eq "." || $_ eq ".."; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_ eq "." or $_ eq ".."
MC/DC0%0/2
$_ eq "." or $_ eq ".."
$_ eq "."
$_ eq ".."
Truth table0%0/3
A or B
A= $_ eq "."B= $_ eq ".."
| |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | if (-f $_) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 74 | 0 | push @entries, File::Spec->catfile($dir,$_); | |||||||||||||||||||||||||||
| 75 | } elsif (-d _) { | ||||||||||||||||||||||||||||
| 76 | 0 | push @entries, File::Spec->catdir($dir,$_); | |||||||||||||||||||||||||||
| 77 | } else { | ||||||||||||||||||||||||||||
| 78 | 0 | $CPAN::Frontend->mywarn("Warning: weird direntry in $dir: $_\n"); | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | 0 | ▶ | chdir $cwd or Carp::croak("Can't chdir to $cwd: $!"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | 0 | sort { -M $a <=> -M $b} @entries; | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | #-> sub CPAN::CacheMgr::disk_usage ; | ||||||||||||||||||||||||||||
| 86 | sub disk_usage { | ||||||||||||||||||||||||||||
| 87 | 0 | ▶ | my($self,$dir,$fast) = @_; | ||||||||||||||||||||||||||
|
Subroutine
disk_usage: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 88 | 0 | ▶ | return if exists $self->{SIZE}{$dir}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | 0 | ▶ | return if $CPAN::Signal; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | 0 | my($Du) = 0; | |||||||||||||||||||||||||||
| 91 | 0 | ▶ | if (-e $dir) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 92 | 0 | ▶ | if (-d $dir) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 93 | 0 | ▶ | unless (-x $dir) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | 0 | ▶ | unless (chmod 0755, $dir) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | 0 | $CPAN::Frontend->mywarn("I have neither the -x permission nor the ". | |||||||||||||||||||||||||||
| 96 | "permission to change the permission; cannot ". | ||||||||||||||||||||||||||||
| 97 | "estimate disk usage of '$dir'\n"); | ||||||||||||||||||||||||||||
| 98 | 0 | $CPAN::Frontend->mysleep(5); | |||||||||||||||||||||||||||
| 99 | 0 | return; | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | } elsif (-f $dir) { | ||||||||||||||||||||||||||||
| 103 | # nothing to say, no matter what the permissions | ||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | } else { | ||||||||||||||||||||||||||||
| 106 | 0 | $CPAN::Frontend->mywarn("File or directory '$dir' has gone, ignoring\n"); | |||||||||||||||||||||||||||
| 107 | 0 | return; | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | 0 | ▶ | if ($fast) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 110 | 0 | $Du = 0; # placeholder | |||||||||||||||||||||||||||
| 111 | } else { | ||||||||||||||||||||||||||||
| 112 | find( | ||||||||||||||||||||||||||||
| 113 | sub { | ||||||||||||||||||||||||||||
| 114 | 0 | ▶ | $File::Find::prune++ if $CPAN::Signal; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | 0 | ▶ | return if -l $_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 116 | 0 | ▶ | if (-d _) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | 0 | ▶ | unless (-x _) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | 0 | ▶ | unless (chmod 0755, $_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 119 | 0 | $CPAN::Frontend->mywarn("I have neither the -x permission nor ". | |||||||||||||||||||||||||||
| 120 | "the permission to change the permission; ". | ||||||||||||||||||||||||||||
| 121 | "can only partially estimate disk usage ". | ||||||||||||||||||||||||||||
| 122 | "of '$_'\n"); | ||||||||||||||||||||||||||||
| 123 | 0 | $CPAN::Frontend->mysleep(5); | |||||||||||||||||||||||||||
| 124 | 0 | return; | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | } else { | ||||||||||||||||||||||||||||
| 128 | 0 | $Du += (-s _); | |||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | }, | ||||||||||||||||||||||||||||
| 131 | 0 | $dir | |||||||||||||||||||||||||||
| 132 | ); | ||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | 0 | ▶ | return if $CPAN::Signal; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 135 | 0 | $self->{SIZE}{$dir} = $Du/1024/1024; | |||||||||||||||||||||||||||
| 136 | 0 | unshift @{$self->{FIFO}}, $dir; | |||||||||||||||||||||||||||
| 137 | 0 | ▶ | $self->debug("measured $dir is $Du") if $CPAN::DEBUG; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 0 | $self->{DU} += $Du/1024/1024; | |||||||||||||||||||||||||||
| 139 | 0 | $self->{DU}; | |||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | #-> sub CPAN::CacheMgr::_clean_cache ; | ||||||||||||||||||||||||||||
| 143 | sub _clean_cache { | ||||||||||||||||||||||||||||
| 144 | 0 | ▶ | my($self,$dir) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_clean_cache: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||
| 145 | 0 | ▶ | return unless -e $dir; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | 0 | ▶ | unless (File::Spec->canonpath(File::Basename::dirname($dir)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | eq File::Spec->canonpath($CPAN::Config->{build_dir})) { | ||||||||||||||||||||||||||||
| 148 | 0 | $CPAN::Frontend->mywarn("Directory '$dir' not below $CPAN::Config->{build_dir}, ". | |||||||||||||||||||||||||||
| 149 | "will not remove\n"); | ||||||||||||||||||||||||||||
| 150 | 0 | $CPAN::Frontend->mysleep(5); | |||||||||||||||||||||||||||
| 151 | 0 | return; | |||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | 0 | ▶ | $self->debug("have to rmtree $dir, will free $self->{SIZE}{$dir}") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 154 | if $CPAN::DEBUG; | ||||||||||||||||||||||||||||
| 155 | 0 | File::Path::rmtree($dir); | |||||||||||||||||||||||||||
| 156 | 0 | my $id_deleted = 0; | |||||||||||||||||||||||||||
| 157 | 0 | ▶ | if ($dir !~ /\.yml$/ && -f "$dir.yml") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $dir =~ /\.yml$/ and -f "$dir.yml"
MC/DC0%0/2
not $dir =~ /\.yml$/ and -f "$dir.yml"
not $dir =~ /\.yml$/
-f "$dir.yml"
Truth table0%0/3
not(A) and B
A= not $dir =~ /\.yml$/B= -f "$dir.yml"
| |||||||||||||||||||||||||||||
| 158 | 0 | my $yaml_module = CPAN::_yaml_module(); | |||||||||||||||||||||||||||
| 159 | 0 | ▶ | if ($CPAN::META->has_inst($yaml_module)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 160 | 0 | my($peek_yaml) = eval { CPAN->_yaml_loadfile("$dir.yml"); }; | |||||||||||||||||||||||||||
| 161 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 162 | 0 | $CPAN::Frontend->mywarn("(parse error on '$dir.yml' removing anyway)"); | |||||||||||||||||||||||||||
| 163 | 0 | ▶ | unlink "$dir.yml" or | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 164 | $CPAN::Frontend->mywarn("(Could not unlink '$dir.yml': $!)"); | ||||||||||||||||||||||||||||
| 165 | 0 | return; | |||||||||||||||||||||||||||
| 166 | } elsif (my $id = $peek_yaml->[0]{distribution}{ID}) { | ||||||||||||||||||||||||||||
| 167 | 0 | $CPAN::META->delete("CPAN::Distribution", $id); | |||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | # XXX we should restore the state NOW, otherwise this | ||||||||||||||||||||||||||||
| 170 | # distro does not exist until we read an index. BUG ALERT(?) | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | # $CPAN::Frontend->mywarn (" +++\n"); | ||||||||||||||||||||||||||||
| 173 | 0 | $id_deleted++; | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | 0 | unlink "$dir.yml"; # may fail | |||||||||||||||||||||||||||
| 177 | 0 | ▶ | unless ($id_deleted) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 178 | 0 | CPAN->debug("no distro found associated with '$dir'"); | |||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | 0 | $self->{DU} -= $self->{SIZE}{$dir}; | |||||||||||||||||||||||||||
| 182 | 0 | delete $self->{SIZE}{$dir}; | |||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | #-> sub CPAN::CacheMgr::new ; | ||||||||||||||||||||||||||||
| 186 | sub new { | ||||||||||||||||||||||||||||
| 187 | 7 | ▶ | my($class,$phase) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=16.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 188 | 7 | ▶ | $phase ||= "atstart"; | ||||||||||||||||||||||||||
|
Condition50%1/2
$phase ||= "atstart"
MC/DC0%0/1
$phase ||= "atstart"
$phase
Truth table50%1/2
A
A= $phase
| |||||||||||||||||||||||||||||
| 189 | 7 | my $time = time; | |||||||||||||||||||||||||||
| 190 | 7 | my($debug,$t2); | |||||||||||||||||||||||||||
| 191 | 7 | $debug = ""; | |||||||||||||||||||||||||||
| 192 | my $self = { | ||||||||||||||||||||||||||||
| 193 | ID => $CPAN::Config->{build_dir}, | ||||||||||||||||||||||||||||
| 194 | MAX => $CPAN::Config->{'build_cache'}, | ||||||||||||||||||||||||||||
| 195 | 7 | ▶ | SCAN => $CPAN::Config->{'scan_cache'} || 'atstart', | ||||||||||||||||||||||||||
|
Condition50%1/2
$CPAN::Config->{'scan_cache'} || 'atstart'
MC/DC0%0/1
$CPAN::Config->{'scan_cache'} || 'atstart'
$CPAN::Config->{'scan_cache'}
Truth table50%1/2
A
A= $CPAN::Config->{'scan_cache'}
| |||||||||||||||||||||||||||||
| 196 | DU => 0 | ||||||||||||||||||||||||||||
| 197 | }; | ||||||||||||||||||||||||||||
| 198 | $CPAN::Frontend->mydie("Unknown scan_cache argument: $self->{SCAN}") | ||||||||||||||||||||||||||||
| 199 | 7 | ▶ | unless $self->{SCAN} =~ /never|atstart|atexit/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 200 | 7 | File::Path::mkpath($self->{ID}); | |||||||||||||||||||||||||||
| 201 | 7 | my $dh = DirHandle->new($self->{ID}); | |||||||||||||||||||||||||||
| 202 | 7 | bless $self, $class; | |||||||||||||||||||||||||||
| 203 | 7 | $self->scan_cache($phase); | |||||||||||||||||||||||||||
| 204 | 7 | $t2 = time; | |||||||||||||||||||||||||||
| 205 | 7 | $debug .= "timing of CacheMgr->new: ".($t2 - $time); | |||||||||||||||||||||||||||
| 206 | 7 | $time = $t2; | |||||||||||||||||||||||||||
| 207 | 7 | ▶ | CPAN->debug($debug) if $CPAN::DEBUG; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 208 | 7 | $self; | |||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | #-> sub CPAN::CacheMgr::scan_cache ; | ||||||||||||||||||||||||||||
| 212 | sub scan_cache { | ||||||||||||||||||||||||||||
| 213 | 7 | ▶ | my ($self, $phase) = @_; | ||||||||||||||||||||||||||
|
Subroutine
scan_cache: called CC=8 SCAR=36.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 214 | 7 | ▶ | $phase = '' unless defined $phase; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 215 | 7 | ▶ | return unless $phase eq $self->{SCAN}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 216 | 7 | ▶ | return unless $CPAN::META->{LOCK}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 217 | $CPAN::Frontend->myprint( | ||||||||||||||||||||||||||||
| 218 | sprintf("Scanning cache %s for sizes\n", | ||||||||||||||||||||||||||||
| 219 | 0 | $self->{ID})); | |||||||||||||||||||||||||||
| 220 | 0 | my $e; | |||||||||||||||||||||||||||
| 221 | 0 | my @entries = $self->entries($self->{ID}); | |||||||||||||||||||||||||||
| 222 | 0 | my $i = 0; | |||||||||||||||||||||||||||
| 223 | 0 | my $painted = 0; | |||||||||||||||||||||||||||
| 224 | 0 | for $e (@entries) { | |||||||||||||||||||||||||||
| 225 | 0 | my $symbol = "."; | |||||||||||||||||||||||||||
| 226 | 0 | ▶ | if ($self->{DU} > $self->{MAX}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 227 | 0 | $symbol = "-"; | |||||||||||||||||||||||||||
| 228 | 0 | $self->disk_usage($e,1); | |||||||||||||||||||||||||||
| 229 | } else { | ||||||||||||||||||||||||||||
| 230 | 0 | $self->disk_usage($e); | |||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | 0 | $i++; | |||||||||||||||||||||||||||
| 233 | 0 | ▶ | while (($painted/76) < ($i/@entries)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 234 | 0 | $CPAN::Frontend->myprint($symbol); | |||||||||||||||||||||||||||
| 235 | 0 | $painted++; | |||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||
| 237 | 0 | ▶ | return if $CPAN::Signal; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||
| 239 | 0 | $CPAN::Frontend->myprint("DONE\n"); | |||||||||||||||||||||||||||
| 240 | 0 | $self->tidyup; | |||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 24 | 1; | |||||||||||||||||||||||||||