Skip to content

Commit

Permalink
make the code better trackable on the undertested connectivity proble…
Browse files Browse the repository at this point in the history
…ms; especially replace one warn with a die that might cause an endless loop on disconnected systems
  • Loading branch information
andk committed Jun 14, 2009
1 parent 90c8c3d commit 3fd6bbc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
28 changes: 22 additions & 6 deletions lib/CPAN/FTP.pm
Expand Up @@ -485,8 +485,7 @@ I would like to connect to one of the following sites to get '%s':
push @mess, qq{The urllist can be edited.},
qq{E.g. with 'o conf urllist push ftp://myurl/'};
$CPAN::Frontend->mywarn(Text::Wrap::wrap("","","@mess"). "\n\n");
$CPAN::Frontend->mywarn("Could not fetch $file\n");
$CPAN::Frontend->mysleep(2);
$CPAN::Frontend->mydie("Could not fetch $file\n");
}
if ($maybe_restore) {
rename "$aslocal.bak$$", $aslocal;
Expand Down Expand Up @@ -682,7 +681,8 @@ sub hostdlhard {
# < /dev/null ";
my($aslocal_dir) = dirname($aslocal);
mkpath($aslocal_dir);
HOSTHARD: for $ro_url (@$host_seq) {
my $some_dl_success = 0;
HOSTHARD: for $ro_url (@$host_seq) {
$self->_set_attempt($stats,"dlhard",$ro_url);
my $url = "$ro_url$file";
my($proto,$host,$dir,$getfile);
Expand All @@ -706,8 +706,8 @@ sub hostdlhard {
my $proxy_vars = $self->_proxy_vars($ro_url);
DLPRG: for my $f (qw(curl wget lynx ncftpget ncftp)) {
my $funkyftp = CPAN::HandleConfig->safe_quote($CPAN::Config->{$f});
next unless defined $funkyftp;
next if $funkyftp =~ /^\s*$/;
next DLPRG unless defined $funkyftp;
next DLPRG if $funkyftp =~ /^\s*$/;

my($asl_ungz, $asl_gz);
($asl_ungz = $aslocal) =~ s/\.gz//;
Expand Down Expand Up @@ -758,6 +758,7 @@ $content
$CPAN::Frontend->mysleep(1);
next DLPRG;
}
$some_dl_success++;
} else {
$CPAN::Frontend->myprint(qq{
No success, the file that lynx has downloaded is an empty file.
Expand All @@ -768,13 +769,20 @@ No success, the file that lynx has downloaded is an empty file.
if ($wstatus == 0) {
if (-s $aslocal) {
# Looks good
$some_dl_success++;
} elsif ($asl_ungz ne $aslocal) {
# test gzip integrity
if (eval{CPAN::Tarzip->new($asl_ungz)->gtest}) {
# e.g. foo.tar is gzipped --> foo.tar.gz
rename $asl_ungz, $aslocal;
$some_dl_success++;
} else {
eval{CPAN::Tarzip->new($asl_gz)->gzip($asl_ungz)};
if ($@) {
warn "Warning: $@";
} else {
$some_dl_success++;
}
}
}
$ThesiteURL = $ro_url;
Expand Down Expand Up @@ -820,8 +828,16 @@ No success, the file that lynx has downloaded is an empty file.
});
}
return if $CPAN::Signal;
} # transfer programs
} # download/transfer programs (DLPRG)
} # host
require Carp;
if ($some_dl_success) {
Carp::cluck("Warning: doesn't seem we had substantial success downloading '$aslocal'. Don't know how to proceed.");
} else {
Carp::cluck("Warning: no success downloading '$aslocal'. Giving up on it.");
}
$CPAN::Frontend->mysleep(5);
return;
}

#-> CPAN::FTP::_proxy_vars
Expand Down
10 changes: 6 additions & 4 deletions lib/CPAN/HandleConfig.pm
Expand Up @@ -123,8 +123,10 @@ sub edit {
my($o,$str,$func,$args,$key_exists);
$o = shift @args;
if($can{$o}) {
$self->$o(args => \@args); # o conf init => sub init => sub load
return 1;
my $success = $self->$o(args => \@args); # o conf init => sub init => sub load
unless ($success) {
die "Panic: could not configure CPAN.pm for args [@args]. Giving up.";
}
} else {
CPAN->debug("o[$o]") if $CPAN::DEBUG;
unless (exists $keys{$o}) {
Expand Down Expand Up @@ -572,9 +574,9 @@ some missing parameters...
END
$args{args} = \@miss;
}
CPAN::FirstTime::init($configpm, %args);
my $initialized = CPAN::FirstTime::init($configpm, %args);
$loading--;
return;
return $initialized;
}


Expand Down

0 comments on commit 3fd6bbc

Please sign in to comment.