diff options
author | Michael Vogt <mvo@debian.org> | 2010-06-10 14:01:18 +0200 |
---|---|---|
committer | Michael Vogt <mvo@debian.org> | 2010-06-10 14:01:18 +0200 |
commit | e934f8c63aabf4ff94962a4602c143b52b19b3cb (patch) | |
tree | 8f4774cc300c0621cc4532b53eef2a04e5e56b3c /methods/mirror.cc | |
parent | 189bb640d2443a5fcaade2ce169429c629ba3148 (diff) | |
parent | 97f4026d93a85838439263d30146c3ad25fef474 (diff) |
merged from david
Diffstat (limited to 'methods/mirror.cc')
-rw-r--r-- | methods/mirror.cc | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/methods/mirror.cc b/methods/mirror.cc index b2b6b2ecf..e8873d97b 100644 --- a/methods/mirror.cc +++ b/methods/mirror.cc @@ -153,11 +153,12 @@ void MirrorMethod::CurrentQueueUriToMirror() return; // find current mirror and select next one - for (int i=0; i < AllMirrors.size(); i++) + for (vector<string>::const_iterator mirror = AllMirrors.begin(); + mirror != AllMirrors.end(); ++mirror) { - if (Queue->Uri.find(AllMirrors[i]) == 0) + if (Queue->Uri.find(*mirror) == 0) { - Queue->Uri.replace(0, AllMirrors[i].size(), BaseUri); + Queue->Uri.replace(0, mirror->length(), BaseUri); return; } } @@ -168,15 +169,19 @@ void MirrorMethod::CurrentQueueUriToMirror() bool MirrorMethod::TryNextMirror() { // find current mirror and select next one - for (int i=0; i < AllMirrors.size()-1; i++) + for (vector<string>::const_iterator mirror = AllMirrors.begin(); + mirror != AllMirrors.end(); ++mirror) { - if (Queue->Uri.find(AllMirrors[i]) == 0) - { - Queue->Uri.replace(0, AllMirrors[i].size(), AllMirrors[i+1]); - if (Debug) - clog << "TryNextMirror: " << Queue->Uri << endl; - return true; - } + if (Queue->Uri.find(*mirror) != 0) + continue; + + vector<string>::const_iterator nextmirror = mirror + 1; + if (nextmirror != AllMirrors.end()) + break; + Queue->Uri.replace(0, mirror->length(), *nextmirror); + if (Debug) + clog << "TryNextMirror: " << Queue->Uri << endl; + return true; } if (Debug) |