summaryrefslogtreecommitdiff
path: root/methods/mirror.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-06-02 16:51:25 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2010-06-02 16:51:25 +0200
commit483dfdd8aced593e966d221073c056c2e332584f (patch)
tree01197e495705cc244744e31d16708de60e6832b5 /methods/mirror.cc
parent96db74ce38e9451609fe33f9e25f3f9d42b1fe22 (diff)
methods/mirror.cc: on fail try the next mirror
Diffstat (limited to 'methods/mirror.cc')
-rw-r--r--methods/mirror.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/methods/mirror.cc b/methods/mirror.cc
index 0a0d07e6b..b8bd6db73 100644
--- a/methods/mirror.cc
+++ b/methods/mirror.cc
@@ -197,7 +197,8 @@ bool MirrorMethod::InitMirrors()
while (!in.eof())
{
getline(in, s);
- AllMirrors.push_back(s);
+ if (s.size() > 0)
+ AllMirrors.push_back(s);
}
SelectNextMirror();
return true;
@@ -314,6 +315,15 @@ bool MirrorMethod::Fetch(FetchItem *Itm)
void MirrorMethod::Fail(string Err,bool Transient)
{
+ // try the next mirror on fail
+ string old_mirror = Mirror;
+ if (SelectNextMirror())
+ {
+ Queue->Uri.replace(0, old_mirror.size(), Mirror);
+ return;
+ }
+
+ // all mirrors failed, so bail out
if(Queue->Uri.find("http://") != string::npos)
Queue->Uri.replace(0,Mirror.size(), BaseUri);
pkgAcqMethod::Fail(Err, Transient);