diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2008-05-15 14:11:16 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2008-05-15 14:11:16 +0000 |
commit | fd1514ba3b0d3c6d918a7a2c68068d927f275a4f (patch) | |
tree | e143e26d1420f4a71812b50b5c8f59b9219401b1 /urpm/media.pm | |
parent | ad267f63d66ffe9455591bc326c376709b8f08b8 (diff) | |
download | urpmi-fd1514ba3b0d3c6d918a7a2c68068d927f275a4f.tar urpmi-fd1514ba3b0d3c6d918a7a2c68068d927f275a4f.tar.gz urpmi-fd1514ba3b0d3c6d918a7a2c68068d927f275a4f.tar.bz2 urpmi-fd1514ba3b0d3c6d918a7a2c68068d927f275a4f.tar.xz urpmi-fd1514ba3b0d3c6d918a7a2c68068d927f275a4f.zip |
- urpmi.addmedia, urpmi.update:
o check downloaded MD5SUM is not invalid HTML code, and try
another mirror from mirrorlist (#39918)
(useful for servers not returning a valid HTTP error)
Diffstat (limited to 'urpm/media.pm')
-rw-r--r-- | urpm/media.pm | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/urpm/media.pm b/urpm/media.pm index 2769c33d..12d7f0cc 100644 --- a/urpm/media.pm +++ b/urpm/media.pm @@ -706,11 +706,8 @@ sub add_medium { # forcing the standard media_info_dir if undefined $medium->{media_info_dir} ||= 'media_info'; - require urpm::mirrors; - urpm::mirrors::try($urpm, $medium, sub { - # this is a little ugly since MD5SUM will be downloaded again later, but it's small enough... - _download_MD5SUM($urpm, $medium); - }) or return; + # this is a little ugly since MD5SUM will be downloaded again later, but it's small enough... + _download_MD5SUM_and_check($urpm, $medium) or return; } if ($with_synthesis) { @@ -1362,7 +1359,26 @@ sub _download_MD5SUM { unlink $cachedir_MD5SUM; urpm::download::sync($urpm, $medium, [ reduce_pathname(_synthesis_dir($medium) . '/MD5SUM') ], - quiet => 1) && file_size($cachedir_MD5SUM) > 32; + quiet => 1) or return; + $cachedir_MD5SUM; +} + +sub _download_MD5SUM_and_check { + my ($urpm, $medium) = @_; + + my ($err, $cachedir_MD5SUM); + require urpm::mirrors; + try__maybe_mirrorlist($urpm, $medium, sub { + $cachedir_MD5SUM = _download_MD5SUM($urpm, $medium) or $err = $@; + $cachedir_MD5SUM && urpm::md5sum::check_file($cachedir_MD5SUM); + }) and return $cachedir_MD5SUM; + + if ($cachedir_MD5SUM) { + $urpm->{error}(N("invalid MD5SUM file (downloaded from %s)", _synthesis_dir($medium))); + } else { + $urpm->{error}(N("...retrieving failed: %s", $err)); + } + undef; } #- options: callback, force, nomd5sum, probe_with, quiet @@ -1378,8 +1394,8 @@ sub _update_medium__parse_if_unmodified__remote { #- to be checked for being valid, nothing can be deduced if no MD5SUM #- file is present. - if (!$options->{nomd5sum} && _download_MD5SUM($urpm, $medium)) { - my $new_MD5SUM = "$urpm->{cachedir}/partial/MD5SUM"; + if (!$options->{nomd5sum}) { + my $new_MD5SUM = _download_MD5SUM_and_check($urpm, $medium) or return; if ($options->{force} < 2 && _is_statedir_MD5SUM_uptodate($urpm, $medium, $new_MD5SUM)) { _medium_is_up_to_date($urpm, $medium); return 'unmodified'; |