mirror of
https://github.com/webmin/webmin.git
synced 2025-07-23 00:30:33 +00:00
Re-try webmin updates fetches 5 times
This commit is contained in:
@ -53,7 +53,7 @@ foreach $url (@urls) {
|
||||
$mtemp = &transname($mfile);
|
||||
$progress_callback_url = $u->[2];
|
||||
$progress_callback_prefix = " " x 10;
|
||||
&http_download($mhost, $mport, $mpage, $mtemp, undef,
|
||||
&retry_http_download($mhost, $mport, $mpage, $mtemp, undef,
|
||||
\&progress_callback, $mssl,
|
||||
$in{'upuser'}, $in{'uppass'});
|
||||
$irv = &check_update_signature($mhost, $mport, $mpage,
|
||||
|
@ -47,7 +47,7 @@ foreach $url (@urls) {
|
||||
&parse_http_url($u->[2], $host, $port, $page, $ssl);
|
||||
($mfile = $mpage) =~ s/^(.*)\///;
|
||||
$mtemp = &transname($mfile);
|
||||
&http_download($mhost, $mport, $mpage, $mtemp, \$error,
|
||||
&retry_http_download($mhost, $mport, $mpage, $mtemp, \$error,
|
||||
undef, $mssl,
|
||||
$config{'upuser'}, $config{'uppass'});
|
||||
if ($error) {
|
||||
|
@ -822,7 +822,7 @@ $host || &error($text{'update_eurl'});
|
||||
|
||||
# Download the file
|
||||
my $temp = &transname();
|
||||
&http_download($host, $port, $page, $temp, undef, undef, $ssl, $user, $pass,
|
||||
&retry_http_download($host, $port, $page, $temp, undef, undef, $ssl, $user, $pass,
|
||||
0, 0, 1);
|
||||
|
||||
# Download the signature, if we can check it
|
||||
@ -830,7 +830,7 @@ my ($ec, $emsg) = &gnupg_setup();
|
||||
if (!$ec && $sigmode) {
|
||||
my $err;
|
||||
my $sig;
|
||||
&http_download($host, $port, $page."-sig.asc", \$sig,
|
||||
&retry_http_download($host, $port, $page."-sig.asc", \$sig,
|
||||
\$err, undef, $ssl, $user, $pass, 0, 0, 1);
|
||||
if ($err) {
|
||||
$sigmode == 2 && &error(&text('update_enosig', $err));
|
||||
@ -2112,4 +2112,34 @@ elsif ($lnk =~ /^[^\/ ]+$/) {
|
||||
return undef;
|
||||
}
|
||||
|
||||
# retry_http_download(host, port, etc..)
|
||||
# Calls http_download until it succeeds
|
||||
sub retry_http_download
|
||||
{
|
||||
my ($host, $port, $page, $dest, $error, $cbfunc, $ssl, $user, $pass,
|
||||
$timeout, $osdn, $nocache, $headers) = @_;
|
||||
my $tries = 5;
|
||||
my $i = 0;
|
||||
my $tryerror;
|
||||
while($i < $tries) {
|
||||
$tryerror = undef;
|
||||
&http_download($host, $port, $page, $dest, \$tryerror, $cbfunc, $ssl, $user,
|
||||
$pass, $timeout, $osdn, $nocache, $headers);
|
||||
if (!$tryerror) {
|
||||
last;
|
||||
}
|
||||
$i++;
|
||||
sleep($i);
|
||||
}
|
||||
if ($tryerror) {
|
||||
# Failed every time
|
||||
if (ref($error)) {
|
||||
$$error = $tryerror;
|
||||
}
|
||||
else {
|
||||
&error($tryerror);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
Reference in New Issue
Block a user