summaryrefslogtreecommitdiffstats
path: root/urpm
diff options
context:
space:
mode:
Diffstat (limited to 'urpm')
-rw-r--r--urpm/download.pm2
-rw-r--r--urpm/md5sum.pm14
-rw-r--r--urpm/media.pm26
3 files changed, 41 insertions, 1 deletions
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;