]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire-item.cc
* added gpgv::Options to configure-index
[apt.git] / apt-pkg / acquire-item.cc
index ada6409367c0ed26f064f36193dadf3e8134878b..de8cfe8f2249e2b74d2aeccd46b93264663bcf94 100644 (file)
@@ -137,7 +137,7 @@ void pkgAcquire::Item::Rename(string From,string To)
    instantiated to fetch the revision file */   
 pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner,
                         string URI,string URIDesc,string ShortDesc,
-                        string ExpectedMD5) :
+                        string ExpectedMD5, string comprExt) :
    Item(Owner), RealURI(URI), ExpectedMD5(ExpectedMD5)
 {
    Decompression = false;
@@ -146,11 +146,17 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner,
    DestFile = _config->FindDir("Dir::State::lists") + "partial/";
    DestFile += URItoFileName(URI);
 
-   // Create the item
-   if(FileExists("/usr/bin/bzip2"))
-      Desc.URI = URI + ".bz2"; 
-   else
-      Desc.URI = URI + ".gz"; 
+   if(comprExt.empty()) 
+   {
+      // autoselect 
+      if(FileExists("/usr/bin/bzip2"))
+        Desc.URI = URI + ".bz2"; 
+      else
+        Desc.URI = URI + ".gz"; 
+   } else {
+      Desc.URI = URI + comprExt; 
+   }
+
    Desc.Description = URIDesc;
    Desc.Owner = this;
    Desc.ShortDesc = ShortDesc;
@@ -179,7 +185,13 @@ void pkgAcqIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
    // no .bz2 found, retry with .gz
    if(Desc.URI.substr(Desc.URI.size()-3,Desc.URI.size()-1) == "bz2") {
       Desc.URI = Desc.URI.substr(0,Desc.URI.size()-3) + "gz"; 
-      QueueURI(Desc);
+
+      // retry with a gzip one 
+      new pkgAcqIndex(Owner, RealURI, Desc.Description,Desc.ShortDesc, 
+                     ExpectedMD5, string(".gz"));
+      Status = StatDone;
+      Complete = false;
+      Dequeue();
       return;
    }
 
@@ -309,6 +321,10 @@ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner,
    DestFile = _config->FindDir("Dir::State::lists") + "partial/";
    DestFile += URItoFileName(URI);
 
+   // remove any partial downloaded sig-file. it may confuse proxies
+   // and is too small to warrant a partial download anyway
+   unlink(DestFile.c_str());
+
    // Create the item
    Desc.Description = URIDesc;
    Desc.Owner = this;
@@ -334,13 +350,20 @@ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner,
 /* The only header we use is the last-modified header. */
 string pkgAcqMetaSig::Custom600Headers()
 {
+   // mvo: we don't really need the last-modified header here
+   //      1) it points to "Final" and that was renamed to "DestFile" 
+   //         so it's never send anyway
+   //      2) because DestFIle is in partial/ we will send a partial request
+   //         with if-range in the http method (or the equivalent for ftp). 
+   //         that should give the same result
+
    string Final = _config->FindDir("Dir::State::lists");
    Final += URItoFileName(RealURI);
    
    struct stat Buf;
    if (stat(Final.c_str(),&Buf) != 0)
       return "\nIndex-File: true";
-   
+
    return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
 }