diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2008-09-23 15:54:24 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2008-09-23 15:54:24 +0000 |
commit | ab25ce721b7bf62841c6d9c1ded8a762fb717784 (patch) | |
tree | acb3d6303153823b69308219646ba8c5b65214c4 | |
parent | 0ff68bc2ce17ed97d22575c250c1d569638c1801 (diff) | |
download | urpmi-ab25ce721b7bf62841c6d9c1ded8a762fb717784.tar urpmi-ab25ce721b7bf62841c6d9c1ded8a762fb717784.tar.gz urpmi-ab25ce721b7bf62841c6d9c1ded8a762fb717784.tar.bz2 urpmi-ab25ce721b7bf62841c6d9c1ded8a762fb717784.tar.xz urpmi-ab25ce721b7bf62841c6d9c1ded8a762fb717784.zip |
- use "versioned" media_info files
(needed for aria2 to handle mirrors not having some media_info/*)
it fixes:
- downloading parts of media_info file from different mirrors and failing to
obtain a valid result
- checking md5sum of media_info files
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | urpm/download.pm | 2 | ||||
-rw-r--r-- | urpm/md5sum.pm | 14 | ||||
-rw-r--r-- | urpm/media.pm | 26 |
4 files changed, 43 insertions, 1 deletions
@@ -1,3 +1,5 @@ +- use "versioned" media_info files + (needed for aria2 to handle mirrors not having some media_info/*) - urpmi.addmedia: o --distrib: do not skip "debug_for=" media (debug media will be added with flag "ignore" if noauto=1) diff --git a/urpm/download.pm b/urpm/download.pm index 8ae9e7f4..d4344d2f 100644 --- a/urpm/download.pm +++ b/urpm/download.pm @@ -661,7 +661,7 @@ sub sync_aria2 { '--lowest-speed-limit=20K', "--timeout", 3, # $CONNECT_TIMEOUT, '--metalink-servers=3', # maximum number of servers to use for one download '--uri-selector=adaptive', "--server-stat-if=$stat_file", "--server-stat-of=$stat_file", - '--max-file-not-found=3', # number of not found errors on different servers before aborting file download + $options->{is_versioned} ? () : '--max-file-not-found=3', # number of not found errors on different servers before aborting file download '--connect-timeout=3', "-Z", "-j1", ($options->{'limit-rate'} ? "--max-download-limit=" . $options->{'limit-rate'} : ()), diff --git a/urpm/md5sum.pm b/urpm/md5sum.pm index cecd5300..b2fe7a0c 100644 --- a/urpm/md5sum.pm +++ b/urpm/md5sum.pm @@ -27,6 +27,20 @@ sub from_MD5SUM__or_warn { $md5sums->{$basename}; } +sub versioned_media_info_file { + my ($urpm, $medium, $basename) = @_; + my $md5sums = $medium->{parsed_md5sum} or $urpm->{log}("$medium->{name} has no md5sum"), return; + + my @l = map { $md5sums->{$_} eq $md5sums->{$basename} && /^(\d{8}-\d{6})-\Q$basename\E$/ ? $1 : () } keys %$md5sums; + + if (@l == 0) { + $urpm->{debug}("no versioned $basename for medium $medium->{name}") if $urpm->{debug}; + } else { + @l > 1 and $urpm->{debug}("multiple versions for $basename for medium $medium->{name}: @l") if $urpm->{debug}; + } + $l[0]; +} + sub compute { my ($file) = @_; eval { require Digest::MD5 }; diff --git a/urpm/media.pm b/urpm/media.pm index aea565ef..34ae11d6 100644 --- a/urpm/media.pm +++ b/urpm/media.pm @@ -1189,6 +1189,22 @@ sub _download_pubkey { sub _download_media_info_file { my ($urpm, $medium, $prefix, $suffix, $options) = @_; + my $versioned_prefix = do { + my $version = urpm::md5sum::versioned_media_info_file($urpm, $medium, "$prefix$suffix"); + $version and $options->{is_versioned} = 1; + $version ? "$version-$prefix" : $prefix; + }; + + my $tmp = _download_media_info_file_raw($urpm, $medium, + $versioned_prefix, $suffix, $options) or return; + my $result = dirname($tmp) . "/$prefix$suffix"; + $tmp eq $result or rename($tmp, $result) or return; + $result; +} + +sub _download_media_info_file_raw { + my ($urpm, $medium, $prefix, $suffix, $options) = @_; + my $name = "$prefix$suffix"; my $result_file = "$urpm->{cachedir}/partial/$name"; my $found; @@ -1717,6 +1733,14 @@ sub _retrieve_media_info_file_and_check_MD5SUM { 1; } +sub _download_temp_md5sum_and_parse { + my ($urpm, $medium) = @_; + + $urpm->{debug}("downloading MD5SUM to know updated versioned metadata filename") if $urpm->{debug}; + my $md5sum_file = _download_MD5SUM($urpm, $medium); + urpm::md5sum::parse($md5sum_file); +} + sub _any_media_info__or_download { my ($urpm, $medium, $prefix, $suffix, $quiet, $o_callback) = @_; @@ -1733,6 +1757,8 @@ sub _any_media_info__or_download { _maybe_in_statedir_MD5SUM($urpm, $medium, "$prefix$suffix") or return; + $medium->{parsed_md5sum} ||= _download_temp_md5sum_and_parse($urpm, $medium); + my $file_in_partial = _download_media_info_file($urpm, $medium, $prefix, $suffix, { quiet => $quiet, callback => $o_callback }) or return; |