ソースを参照

* apt-pkg/acquire-item.{cc,h}:
- make the authentication download code more robust against
servers/proxies with broken If-Range implementations

Michael Vogt 18 年 前
コミット
aefa6fa625
共有5 個のファイルを変更した441 個の追加349 個の削除を含む
  1. 15 6
      apt-pkg/acquire-item.cc
  2. 4 0
      apt-pkg/acquire-item.h
  3. 1 1
      configure.in
  4. 3 0
      debian/changelog
  5. 418 342
      po/apt-all.pot

+ 15 - 6
apt-pkg/acquire-item.cc

@@ -820,16 +820,19 @@ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner,
    Desc.Owner = this;
    Desc.Owner = this;
    Desc.ShortDesc = ShortDesc;
    Desc.ShortDesc = ShortDesc;
    Desc.URI = URI;
    Desc.URI = URI;
-   
       
       
    string Final = _config->FindDir("Dir::State::lists");
    string Final = _config->FindDir("Dir::State::lists");
    Final += URItoFileName(RealURI);
    Final += URItoFileName(RealURI);
    struct stat Buf;
    struct stat Buf;
    if (stat(Final.c_str(),&Buf) == 0)
    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);
    QueueURI(Desc);
@@ -841,7 +844,7 @@ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner,
 string pkgAcqMetaSig::Custom600Headers()
 string pkgAcqMetaSig::Custom600Headers()
 {
 {
    struct stat Buf;
    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";
 
 
    return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
    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;
    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
    // queue a pkgAcqMetaIndex to be verified against the sig we just retrieved
    new pkgAcqMetaIndex(Owner, MetaIndexURI, MetaIndexURIDesc, MetaIndexShortDesc,
    new pkgAcqMetaIndex(Owner, MetaIndexURI, MetaIndexURIDesc, MetaIndexShortDesc,
 		       DestFile, IndexTargets, MetaIndexParser);
 		       DestFile, IndexTargets, MetaIndexParser);
@@ -887,7 +896,7 @@ void pkgAcqMetaSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
       Item::Failed(Message,Cnf);
       Item::Failed(Message,Cnf);
       // move the sigfile back on transient network failures 
       // move the sigfile back on transient network failures 
       if(FileExists(DestFile))
       if(FileExists(DestFile))
- 	 Rename(DestFile,Final);
+ 	 Rename(LastGoodSig,Final);
 
 
       // set the status back to , Item::Failed likes to reset it
       // set the status back to , Item::Failed likes to reset it
       Status = pkgAcquire::Item::StatTransientNetworkError;
       Status = pkgAcquire::Item::StatTransientNetworkError;

+ 4 - 0
apt-pkg/acquire-item.h

@@ -622,6 +622,10 @@ struct IndexTarget
 class pkgAcqMetaSig : public pkgAcquire::Item
 class pkgAcqMetaSig : public pkgAcquire::Item
 {
 {
    protected:
    protected:
+   /** \brief The last good signature file */
+   string LastGoodSig;
+
+
    /** \brief The fetch request that is currently being processed. */
    /** \brief The fetch request that is currently being processed. */
    pkgAcquire::ItemDesc Desc;
    pkgAcquire::ItemDesc Desc;
 
 

+ 1 - 1
configure.in

@@ -18,7 +18,7 @@ AC_CONFIG_AUX_DIR(buildlib)
 AC_CONFIG_HEADER(include/config.h:buildlib/config.h.in include/apti18n.h:buildlib/apti18n.h.in)
 AC_CONFIG_HEADER(include/config.h:buildlib/config.h.in include/apti18n.h:buildlib/apti18n.h.in)
 
 
 dnl -- SET THIS TO THE RELEASE VERSION --
 dnl -- SET THIS TO THE RELEASE VERSION --
-AC_DEFINE_UNQUOTED(VERSION,"0.7.9ubuntu1")
+AC_DEFINE_UNQUOTED(VERSION,"0.7.9ubuntu1~ppa1")
 PACKAGE="apt"
 PACKAGE="apt"
 AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE")
 AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE")
 AC_SUBST(PACKAGE)
 AC_SUBST(PACKAGE)

+ 3 - 0
debian/changelog

@@ -24,6 +24,9 @@ apt (0.7.9ubuntu1) hardy; urgency=low
     - fix error output
     - fix error output
   * methods/mirror.{cc,h}:
   * methods/mirror.{cc,h}:
     - only update mirror list on IndexFile updates 
     - only update mirror list on IndexFile updates 
+  * apt-pkg/acquire-item.{cc,h}:
+    - make the authentication download code more robust against
+      servers/proxies with broken If-Range implementations
 
 
   [ Chris Cheney ]
   [ Chris Cheney ]
   * ftparchive/contents.cc:
   * ftparchive/contents.cc:

ファイルの差分が大きいため隠しています
+ 418 - 342
po/apt-all.pot