summaryrefslogtreecommitdiffstats
path: root/urpm/mirrors.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-09-22 15:10:33 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-09-22 15:10:33 +0000
commit24aa6a3f929b169380d26b49a8987a91ffdfbdd7 (patch)
tree9155817d72b18eed5bccf2faa5aeeca47c2747f7 /urpm/mirrors.pm
parent04e33808f89abcccba8556b6058c526626c26e22 (diff)
downloadurpmi-24aa6a3f929b169380d26b49a8987a91ffdfbdd7.tar
urpmi-24aa6a3f929b169380d26b49a8987a91ffdfbdd7.tar.gz
urpmi-24aa6a3f929b169380d26b49a8987a91ffdfbdd7.tar.bz2
urpmi-24aa6a3f929b169380d26b49a8987a91ffdfbdd7.tar.xz
urpmi-24aa6a3f929b169380d26b49a8987a91ffdfbdd7.zip
create urpm::mirrors::try_probe() as a alternative solution to
urpm::mirrors::try() which ensure wrong path given by the user doesn't lead to mirrors being all blacklisted
Diffstat (limited to 'urpm/mirrors.pm')
-rw-r--r--urpm/mirrors.pm21
1 files changed, 21 insertions, 0 deletions
diff --git a/urpm/mirrors.pm b/urpm/mirrors.pm
index bee7a8b0..37a06b40 100644
--- a/urpm/mirrors.pm
+++ b/urpm/mirrors.pm
@@ -24,6 +24,27 @@ sub try {
0;
}
+#- similar to try() above, but failure is "normal"
+#- (useful when we lookup a file)
+#-
+#- $medium fields used: mirrorlist, with-dir
+#- side-effects: $medium->{url}
+#- + those of list_urls ($urpm->{mirrors_cache})
+sub try_probe {
+ my ($urpm, $medium, $try) = @_;
+
+ my $nb = 0;
+ foreach my $mirror (map { @$_ } list_urls($urpm, $medium, '')) {
+ $nb++ < $urpm->{options}{'max-round-robin-probes'} or last;
+ my $url = $mirror->{url};
+ $nb > 1 ? $urpm->{info}(N("trying again with mirror %s", $url))
+ : $urpm->{log}("using mirror $url");
+ $medium->{url} = _add__with_dir($url, $medium->{'with-dir'});
+ $try->() and return 1;
+ }
+ 0;
+}
+
#- side-effects: none
sub _add__with_dir {
my ($url, $with_dir) = @_;