From: Michael Vogt Date: Wed, 2 Jun 2010 21:30:01 +0000 (+0200) Subject: implement Fail-Ignore bool in FetchItem that tells the method that a failure of this... X-Git-Tag: 0.8.0~9^2~41^2~1 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/963b16dcebba149ae2c35bd255b34242923fbea0 implement Fail-Ignore bool in FetchItem that tells the method that a failure of this item is ok and does not need to be tried on all mirrors --- diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index a959253bc..3cc2c8717 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -820,6 +820,13 @@ pkgAcqIndexTrans::pkgAcqIndexTrans(pkgAcquire *Owner, string URI,string URIDesc,string ShortDesc) : pkgAcqIndex(Owner, URI, URIDesc, ShortDesc, HashString(), "") { +} + /*}}}*/ +// AcqIndexTrans::Custom600Headers - Insert custom request headers /*{{{*/ +// --------------------------------------------------------------------- +string pkgAcqIndexTrans::Custom600Headers() +{ + return "\nFail-Ignore: true"; } /*}}}*/ // AcqIndexTrans::Failed - Silence failure messages for missing files /*{{{*/ diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 06fcffc73..3ac8a19e2 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -573,6 +573,7 @@ class pkgAcqIndexTrans : public pkgAcqIndex public: virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); + virtual string Custom600Headers(); /** \brief Create a pkgAcqIndexTrans. * diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc index 3008c8d1a..6e021a445 100644 --- a/apt-pkg/acquire-method.cc +++ b/apt-pkg/acquire-method.cc @@ -381,6 +381,7 @@ int pkgAcqMethod::Run(bool Single) if (StrToTime(LookupTag(Message,"Last-Modified"),Tmp->LastModified) == false) Tmp->LastModified = 0; Tmp->IndexFile = StringToBool(LookupTag(Message,"Index-File"),false); + Tmp->FailIgnore = StringToBool(LookupTag(Message,"Fail-Ignore"),false); Tmp->Next = 0; // Append it to the list diff --git a/apt-pkg/acquire-method.h b/apt-pkg/acquire-method.h index 99a4605b1..03851e823 100644 --- a/apt-pkg/acquire-method.h +++ b/apt-pkg/acquire-method.h @@ -37,6 +37,7 @@ class pkgAcqMethod string DestFile; time_t LastModified; bool IndexFile; + bool FailIgnore; }; struct FetchResult diff --git a/methods/mirror.cc b/methods/mirror.cc index cfc155f58..ea0fba438 100644 --- a/methods/mirror.cc +++ b/methods/mirror.cc @@ -162,24 +162,26 @@ void MirrorMethod::CurrentQueueUriToMirror() } } _error->Error("Internal error: Failed to convert %s back to %s", - Queue->Uri, BaseUri); + Queue->Uri.c_str(), BaseUri.c_str()); } bool MirrorMethod::TryNextMirror() { - if(Debug) - cerr << "using mirror: " << Mirror << endl; - // find current mirror and select next one for (int i=0; i < AllMirrors.size()-1; i++) { 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 (Debug) + clog << "TryNextMirror could not find another mirror to try" << endl; + return false; } @@ -307,15 +309,12 @@ bool MirrorMethod::Fetch(FetchItem *Itm) return false; } } - if(Debug) - clog << "selected mirror: " << Mirror << endl; + if(Itm->Uri.find("mirror://") != string::npos) + Itm->Uri.replace(0,BaseUri.size(), Mirror); - for (FetchItem *I = Queue; I != 0; I = I->Next) - { - if(I->Uri.find("mirror://") != string::npos) - I->Uri.replace(0,BaseUri.size(), Mirror); - } + if(Debug) + clog << "Fetch: " << Itm->Uri << endl << endl; // now run the real fetcher return HttpMethod::Fetch(Itm); @@ -324,7 +323,7 @@ bool MirrorMethod::Fetch(FetchItem *Itm) void MirrorMethod::Fail(string Err,bool Transient) { // try the next mirror on fail - if (TryNextMirror()) + if (!Queue->FailIgnore && TryNextMirror()) return; // all mirrors failed, so bail out