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;
}
}
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)
DownloadMirrorFile(Itm->Uri);
}
- if(Mirror.empty()) {
+ if(AllMirrors.empty()) {
if(!InitMirrors()) {
// no valid mirror selected, something went wrong downloading
// from the master mirror site most likely and there is
void MirrorMethod::Fail(string Err,bool Transient)
{
- // try the next mirror on fail
+ // FIXME: TryNextMirror is not ideal for indexfile as we may
+ // run into auth issues
+
+ if (Debug)
+ clog << "Failure to get " << Queue->Uri << endl;
+
+ // try the next mirror on fail (if its not a expected failure,
+ // e.g. translations are ok to ignore)
if (!Queue->FailIgnore && TryNextMirror())
return;