summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2007-12-07 16:21:47 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2007-12-07 16:21:47 +0100
commitaefa6fa625b07dd9d819d0aff30c229428bbc424 (patch)
treef81c98927248770bdcc8322f0cd2d9b2cda18341 /apt-pkg
parent0df1d3ac4312a2051b10478cf1c8b242864cb3b1 (diff)
parentef9425971e042680337120e5efaa628470ad68c4 (diff)
* apt-pkg/acquire-item.{cc,h}:
- make the authentication download code more robust against servers/proxies with broken If-Range implementations
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc21
-rw-r--r--apt-pkg/acquire-item.h4
2 files changed, 19 insertions, 6 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 8d647cdf2..d0eee0b43 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -820,16 +820,19 @@ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner,
Desc.Owner = this;
Desc.ShortDesc = ShortDesc;
Desc.URI = URI;
-
string Final = _config->FindDir("Dir::State::lists");
Final += URItoFileName(RealURI);
struct stat Buf;
if (stat(Final.c_str(),&Buf) == 0)
{
- // File was already in place. It needs to be re-verified
- // because Release might have changed, so Move it into partial
- Rename(Final,DestFile);
+ // File was already in place. It needs to be re-downloaded/verified
+ // because Release might have changed, we do give it a differnt
+ // name than DestFile because otherwise the http method will
+ // send If-Range requests and there are too many broken servers
+ // out there that do not understand them
+ LastGoodSig = DestFile+".reverify";
+ Rename(Final,LastGoodSig);
}
QueueURI(Desc);
@@ -841,7 +844,7 @@ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner,
string pkgAcqMetaSig::Custom600Headers()
{
struct stat Buf;
- if (stat(DestFile.c_str(),&Buf) != 0)
+ if (stat(LastGoodSig.c_str(),&Buf) != 0)
return "\nIndex-File: true";
return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
@@ -871,6 +874,12 @@ void pkgAcqMetaSig::Done(string Message,unsigned long Size,string MD5,
Complete = true;
+ // put the last known good file back on i-m-s hit (it will
+ // be re-verified again)
+ // Else do nothing, we have the new file in DestFile then
+ if(StringToBool(LookupTag(Message,"IMS-Hit"),false) == true)
+ Rename(LastGoodSig, DestFile);
+
// queue a pkgAcqMetaIndex to be verified against the sig we just retrieved
new pkgAcqMetaIndex(Owner, MetaIndexURI, MetaIndexURIDesc, MetaIndexShortDesc,
DestFile, IndexTargets, MetaIndexParser);
@@ -887,7 +896,7 @@ void pkgAcqMetaSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
Item::Failed(Message,Cnf);
// move the sigfile back on transient network failures
if(FileExists(DestFile))
- Rename(DestFile,Final);
+ Rename(LastGoodSig,Final);
// set the status back to , Item::Failed likes to reset it
Status = pkgAcquire::Item::StatTransientNetworkError;
diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h
index 802d8d1ff..5088a41ae 100644
--- a/apt-pkg/acquire-item.h
+++ b/apt-pkg/acquire-item.h
@@ -622,6 +622,10 @@ struct IndexTarget
class pkgAcqMetaSig : public pkgAcquire::Item
{
protected:
+ /** \brief The last good signature file */
+ string LastGoodSig;
+
+
/** \brief The fetch request that is currently being processed. */
pkgAcquire::ItemDesc Desc;