]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire-item.cc
Sync with apt@packages.debian.org/apt--main--0--patch-75
[apt.git] / apt-pkg / acquire-item.cc
index ada6409367c0ed26f064f36193dadf3e8134878b..3df9f24073094b8d3a2a6837c85518a536d33662 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;
    }
 
@@ -295,6 +307,35 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string MD5,
    Mode = decompProg;
 }
 
+// AcqIndexTrans::pkgAcqIndexTrans - Constructor                       /*{{{*/
+// ---------------------------------------------------------------------
+/* The Translation file is added to the queue */
+pkgAcqIndexTrans::pkgAcqIndexTrans(pkgAcquire *Owner,
+                           string URI,string URIDesc,string ShortDesc) :
+                      pkgAcqIndex(Owner, URI, URIDesc, ShortDesc, "", "")
+{
+}
+
+                                                                       /*}}}*/
+// AcqIndexTrans::Failed - Silence failure messages for missing files  /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+void pkgAcqIndexTrans::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
+{
+   if (Cnf->LocalOnly == true || 
+       StringToBool(LookupTag(Message,"Transient-Failure"),false) == false)
+   {      
+      // Ignore this
+      Status = StatDone;
+      Complete = false;
+      Dequeue();
+      return;
+   }
+   
+   Item::Failed(Message,Cnf);
+}
+                                                                       /*}}}*/
+
 pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner,
                             string URI,string URIDesc,string ShortDesc,
                             string MetaIndexURI, string MetaIndexURIDesc,
@@ -309,6 +350,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 +379,10 @@ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner,
 /* The only header we use is the last-modified header. */
 string pkgAcqMetaSig::Custom600Headers()
 {
-   string Final = _config->FindDir("Dir::State::lists");
-   Final += URItoFileName(RealURI);
-   
    struct stat Buf;
-   if (stat(Final.c_str(),&Buf) != 0)
+   if (stat(DestFile.c_str(),&Buf) != 0)
       return "\nIndex-File: true";
-   
+
    return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
 }