| 1 | # -*- Mode: cperl; coding: utf-8; cperl-indent-level: 4 -*- | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # vim: ts=4 sts=4 sw=4: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | package CPAN::CacheMgr; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 26 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 26 | ▶ | use CPAN::InfoObj; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 26 | @CPAN::CacheMgr::ISA = qw(CPAN::InfoObj CPAN); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 26 | ▶ | use Cwd qw(chdir); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 26 | ▶ | use File::Find; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 26 | ▶ | use vars qw( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | $VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 26 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 26 | $VERSION = "5.5003"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | package CPAN::CacheMgr; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 26 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | #-> sub CPAN::CacheMgr::as_string ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | sub as_string { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | eval { require Data::Dumper }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | 0 | ▶ | sub cachesize { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cachesize: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | shift->{DU}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cachesize: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | #-> sub CPAN::CacheMgr::tidyup ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | sub tidyup { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tidyup: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | my($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tidyup: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | return unless $CPAN::META->{LOCK}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | return unless -d $self->{ID}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 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: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $self->_clean_cache($toremove); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | return if $CPAN::Signal; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $self->{FIFO} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | #-> sub CPAN::CacheMgr::dir ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 7 | ▶ | sub dir { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dir: called CC=1 SCAR=1.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | shift->{ID}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dir: not called CC=1 SCAR=1.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | #-> sub CPAN::CacheMgr::entries ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | sub entries { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
entries: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | my($self,$dir) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
entries: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | return unless defined $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | $self->debug("reading dir[$dir]") if $CPAN::DEBUG; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | $dir ||= $self->{ID}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$dir ||= $self->{"ID"}
$dir ||= $self->{"ID"}
MC/DC0%0/2
$dir ||= $self->{"ID"}
$dir
$self->{"ID"}
MC/DC0%0/2
$dir ||= $self->{"ID"}
$dir
$self->{"ID"}
Truth table0%0/3
A ||= B
A= $dirB= $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: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | my $dh = DirHandle->new(File::Spec->curdir) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | or Carp::croak("Couldn't opendir $dir: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | my(@entries); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | for ($dh->read) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | next if $_ eq "." || $_ eq ".."; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
$_ eq "." or $_ eq ".."
$_ eq "." or $_ eq ".."
MC/DC0%0/2
$_ eq "." or $_ eq ".."
$_ eq "."
$_ eq ".."
MC/DC0%0/2
$_ eq "." or $_ eq ".."
$_ eq "."
$_ eq ".."
Truth table0%0/3
A or B
A= $_ eq "."B= $_ eq ".."
Truth table0%0/3
A or B
A= $_ eq "."B= $_ eq ".."
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | if (-f $_) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 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: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | sort { -M $a <=> -M $b} @entries; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | #-> sub CPAN::CacheMgr::disk_usage ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | sub disk_usage { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
disk_usage: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 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: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | return if $CPAN::Signal; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my($Du) = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | if (-e $dir) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | if (-d $dir) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | unless (-x $dir) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | unless (chmod 0755, $dir) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 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: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | $Du = 0; # placeholder | |||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | find( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | $File::Find::prune++ if $CPAN::Signal; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | return if -l $_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | if (-d _) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | unless (-x _) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | unless (chmod 0755, $_) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 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: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 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: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $self->{DU} += $Du/1024/1024; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | $self->{DU}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | #-> sub CPAN::CacheMgr::_clean_cache ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | sub _clean_cache { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_clean_cache: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | my($self,$dir) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_clean_cache: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | return unless -e $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | unless (File::Spec->canonpath(File::Basename::dirname($dir)) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 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: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 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: 2 branches
Condition0%0/6
not $dir =~ /\.yml$/ and -f "$dir.yml"
not $dir =~ /\.yml$/ and -f "$dir.yml"
MC/DC0%0/2
not $dir =~ /\.yml$/ and -f "$dir.yml"
not $dir =~ /\.yml$/
-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"
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: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | my($peek_yaml) = eval { CPAN->_yaml_loadfile("$dir.yml"); }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | $CPAN::Frontend->mywarn("(parse error on '$dir.yml' removing anyway)"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | unlink "$dir.yml" or | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 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: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | 7 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=23.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | my($class,$phase) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=5 SCAR=23.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | $phase ||= "atstart"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition25%1/4
$phase ||= "atstart"
$phase ||= "atstart"
MC/DC0%0/1
$phase ||= "atstart"
$phase
MC/DC0%0/1
$phase ||= "atstart"
$phase
Truth table50%1/2
A
A= $phase
Truth table0%0/2
A
A= $phase
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | my $time = time; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | my($debug,$t2); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | $debug = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | my $self = { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | ID => $CPAN::Config->{build_dir}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | MAX => $CPAN::Config->{'build_cache'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | SCAN => $CPAN::Config->{'scan_cache'} || 'atstart', | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition25%1/4
$CPAN::Config->{'scan_cache'} || 'atstart'
$CPAN::Config->{'scan_cache'} || 'atstart'
MC/DC0%0/1
$CPAN::Config->{'scan_cache'} || 'atstart'
$CPAN::Config->{'scan_cache'}
MC/DC0%0/1
$CPAN::Config->{'scan_cache'} || 'atstart'
$CPAN::Config->{'scan_cache'}
Truth table50%1/2
A
A= $CPAN::Config->{'scan_cache'}
Truth table0%0/2
A
A= $CPAN::Config->{'scan_cache'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | DU => 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | $CPAN::Frontend->mydie("Unknown scan_cache argument: $self->{SCAN}") | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | unless $self->{SCAN} =~ /never|atstart|atexit/; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | File::Path::mkpath($self->{ID}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | my $dh = DirHandle->new($self->{ID}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | $self->scan_cache($phase); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | $t2 = time; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | $debug .= "timing of CacheMgr->new: ".($t2 - $time); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $time = $t2; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | CPAN->debug($debug) if $CPAN::DEBUG; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | #-> sub CPAN::CacheMgr::scan_cache ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 7 | ▶ | sub scan_cache { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scan_cache: called CC=8 SCAR=39.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | my ($self, $phase) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scan_cache: not called CC=8 SCAR=39.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | $phase = '' unless defined $phase; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | return unless $phase eq $self->{SCAN}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | return unless $CPAN::META->{LOCK}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 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: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 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: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | $CPAN::Frontend->myprint($symbol); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $painted++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | return if $CPAN::Signal; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | $CPAN::Frontend->myprint("DONE\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | $self->tidyup; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 26 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||