Skip to content

Commit

Permalink
* may work with a missing reports file
Browse files Browse the repository at this point in the history
  • Loading branch information
eserte committed Apr 8, 2012
1 parent 8f397a7 commit 5cc41ed
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions utils/cpan_allpackages
Expand Up @@ -251,34 +251,36 @@ sub parse_reports_sent { # takes ~3 seconds
my %dist;
my $cpan_reporter_dir = $ENV{PERL_CPAN_REPORTER_DIR} || "$ENV{HOME}/.cpanreporter";
my $reports_sent_file = "$cpan_reporter_dir/reports-sent.db";
open my $fh, $reports_sent_file
or die "Can't open $reports_sent_file: $!";
while(<$fh>) {
next if /^#/;
chomp;
if (my($phase, $action, $dist, $perl, $arch) =
if (!open my $fh, $reports_sent_file) {
warn "Can't open $reports_sent_file: $!, skip this part...\n";
} else {
while(<$fh>) {
next if /^#/;
chomp;
if (my($phase, $action, $dist, $perl, $arch) =
$_ =~ m{^
(\S+)\s+
(\S+)\s+
(\S+)\s+
\(([^\)]+)\)\s+
(.+)
$}x) {
my $d = CPAN::DistnameInfo->new($dist.".tar.gz");
my $maturity = $d->maturity;
if (my $old_d = $dist{$maturity}->{$d->dist}->{$perl}->{$arch}) {
if (safe_version($d->version) < safe_version($old_d->{dist}->version)) {
next;
} elsif (safe_version($d->version) == safe_version($old_d->{dist}->version)) {
$dist{$maturity}->{$d->dist}->{$perl}->{$arch}->{result} .= ", $phase $action";
next;
my $d = CPAN::DistnameInfo->new($dist.".tar.gz");
my $maturity = $d->maturity;
if (my $old_d = $dist{$maturity}->{$d->dist}->{$perl}->{$arch}) {
if (safe_version($d->version) < safe_version($old_d->{dist}->version)) {
next;
} elsif (safe_version($d->version) == safe_version($old_d->{dist}->version)) {
$dist{$maturity}->{$d->dist}->{$perl}->{$arch}->{result} .= ", $phase $action";
next;
}
}
$dist{$maturity}->{$d->dist}->{$perl}->{$arch} = {dist => $d,
result => "$phase $action",
};
} else {
warn "Cannot parse line $_";
}
$dist{$maturity}->{$d->dist}->{$perl}->{$arch} = {dist => $d,
result => "$phase $action",
};
} else {
warn "Cannot parse line $_";
}
}
\%dist;
Expand Down

0 comments on commit 5cc41ed

Please sign in to comment.