summaryrefslogtreecommitdiffstats
path: root/urpm/mirrors.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-03-18 13:53:38 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-03-18 13:53:38 +0000
commited0e1f07de9e3f52f20c29c0d2e34de5f9ba9cce (patch)
tree102c71608dff1ff7803a5b2cbbb831599fa03050 /urpm/mirrors.pm
parent24b186c4cc1b340f8d8cfeb9f12959b5e4f357e0 (diff)
downloadurpmi-ed0e1f07de9e3f52f20c29c0d2e34de5f9ba9cce.tar
urpmi-ed0e1f07de9e3f52f20c29c0d2e34de5f9ba9cce.tar.gz
urpmi-ed0e1f07de9e3f52f20c29c0d2e34de5f9ba9cce.tar.bz2
urpmi-ed0e1f07de9e3f52f20c29c0d2e34de5f9ba9cce.tar.xz
urpmi-ed0e1f07de9e3f52f20c29c0d2e34de5f9ba9cce.zip
create _pick_one_
(needed for next commit)
Diffstat (limited to 'urpm/mirrors.pm')
-rw-r--r--urpm/mirrors.pm19
1 files changed, 14 insertions, 5 deletions
diff --git a/urpm/mirrors.pm b/urpm/mirrors.pm
index 1a671caa..8d39c897 100644
--- a/urpm/mirrors.pm
+++ b/urpm/mirrors.pm
@@ -43,6 +43,18 @@ sub pick_one {
sub _pick_one {
my ($urpm, $mirrorlist, $must_succeed, $allow_cache_update) = @_;
+ my $url;
+ if (my $cache = _pick_one_($urpm, $mirrorlist, $allow_cache_update)) {
+ $url = $cache->{chosen};
+ }
+ !$url && $must_succeed and $urpm->{fatal}(10, N("Could not find a mirror from mirrorlist %s", $mirrorlist));
+ $url;
+}
+
+#- side-effects: $urpm->{mirrors_cache}
+sub _pick_one_ {
+ my ($urpm, $mirrorlist, $allow_cache_update) = @_;
+
my $cache = _cache__may_clean_if_outdated($urpm, $mirrorlist, $allow_cache_update);
if (!$cache->{chosen}) {
@@ -51,10 +63,7 @@ sub _pick_one {
$cache->{time} = time();
}
- $cache->{chosen} = $cache->{list}[0]{url} or do {
- $must_succeed and $urpm->{fatal}(10, N("Could not find a mirror from mirrorlist %s", $mirrorlist));
- return;
- };
+ $cache->{chosen} = $cache->{list}[0]{url} or return;
_save_cache($urpm);
}
if ($cache->{nb_uses}++) {
@@ -63,7 +72,7 @@ sub _pick_one {
$urpm->{log}("using mirror $cache->{chosen}");
}
- $cache->{chosen};
+ $cache;
}
#- side-effects: $urpm->{mirrors_cache}
sub black_list {