]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire-item.cc
Add new pkgAcqBaseIndex as base class for pkgAcq{DiffIndex,IndexMerge,pkgAcqBaseIndex...
[apt.git] / apt-pkg / acquire-item.cc
index 913764f64ce04fdc91238a0f3066a4b29209bf50..b3d67de2cd3cec95ff2a4d55ff7ad8e3c6b0201e 100644 (file)
@@ -346,9 +346,7 @@ pkgAcqDiffIndex::pkgAcqDiffIndex(pkgAcquire *Owner,
                                  IndexTarget const *Target,
                                 HashString ExpectedHash,
                                  indexRecords *MetaIndexParser)
-   : Item(Owner), ExpectedHash(ExpectedHash), Target(Target),
-     MetaIndexParser(MetaIndexParser)
-     
+   : pkgAcqBaseIndex(Owner, Target, ExpectedHash, MetaIndexParser)
 {
    
    Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
@@ -446,8 +444,8 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile)          /*{{{*/
            std::clog << "Package file is up-to-date" << std::endl;
         // list cleanup needs to know that this file as well as the already
         // present index is ours, so we create an empty diff to save it for us
-        new pkgAcqIndexDiffs(Owner, RealURI, Description, Desc.ShortDesc,
-              ExpectedHash, ServerSha1, available_patches);
+        new pkgAcqIndexDiffs(Owner, Target, ExpectedHash, MetaIndexParser, 
+                              ServerSha1, available_patches);
         return true;
       }
       else
@@ -532,14 +530,19 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string IndexDiffFile)                /*{{{*/
         }
 
         if (pdiff_merge == false)
-           new pkgAcqIndexDiffs(Owner, RealURI, Description, Desc.ShortDesc,
-                 ExpectedHash, ServerSha1, available_patches);
-        else
+         {
+           new pkgAcqIndexDiffs(Owner, Target, ExpectedHash, MetaIndexParser,
+                                 ServerSha1, available_patches);
+         }
+         else
         {
            std::vector<pkgAcqIndexMergeDiffs*> *diffs = new std::vector<pkgAcqIndexMergeDiffs*>(available_patches.size());
            for(size_t i = 0; i < available_patches.size(); ++i)
-              (*diffs)[i] = new pkgAcqIndexMergeDiffs(Owner, RealURI, Description, Desc.ShortDesc, ExpectedHash,
-                    available_patches[i], diffs);
+              (*diffs)[i] = new pkgAcqIndexMergeDiffs(Owner, Target,
+                                                       ExpectedHash,
+                                                       MetaIndexParser,
+                                                       available_patches[i],
+                                                       diffs);
         }
 
         Complete = false;
@@ -606,22 +609,24 @@ void pkgAcqDiffIndex::Done(string Message,unsigned long long Size,string Md5Hash
  * for each diff and the index
  */
 pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire *Owner,
-                                  string URI,string URIDesc,string ShortDesc,
-                                  HashString ExpectedHash, 
+                                   struct IndexTarget const * const Target,
+                                   HashString ExpectedHash,
+                                   indexRecords *MetaIndexParser,
                                   string ServerSha1,
                                   vector<DiffInfo> diffs)
-   : Item(Owner), RealURI(URI), ExpectedHash(ExpectedHash), 
+   : pkgAcqBaseIndex(Owner, Target, ExpectedHash, MetaIndexParser),
      available_patches(diffs), ServerSha1(ServerSha1)
 {
    
    DestFile = _config->FindDir("Dir::State::lists") + "partial/";
-   DestFile += URItoFileName(URI);
+   DestFile += URItoFileName(Target->URI);
 
    Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
 
-   Description = URIDesc;
+   RealURI = Target->URI;
    Desc.Owner = this;
-   Desc.ShortDesc = ShortDesc;
+   Description = Target->Description;
+   Desc.ShortDesc = Target->ShortDesc;
 
    if(available_patches.empty() == true)
    {
@@ -641,8 +646,7 @@ void pkgAcqIndexDiffs::Failed(string Message,pkgAcquire::MethodConfig * /*Cnf*/)
    if(Debug)
       std::clog << "pkgAcqIndexDiffs failed: " << Desc.URI << " with " << Message << std::endl
                << "Falling back to normal index file acquire" << std::endl;
-   new pkgAcqIndex(Owner, RealURI, Description,Desc.ShortDesc, 
-                  ExpectedHash);
+   new pkgAcqIndex(Owner, Target, ExpectedHash, MetaIndexParser);
    Finish();
 }
                                                                        /*}}}*/
@@ -782,8 +786,9 @@ void pkgAcqIndexDiffs::Done(string Message,unsigned long long Size,string Md5Has
 
       // see if there is more to download
       if(available_patches.empty() == false) {
-        new pkgAcqIndexDiffs(Owner, RealURI, Description, Desc.ShortDesc,
-                             ExpectedHash, ServerSha1, available_patches);
+        new pkgAcqIndexDiffs(Owner, Target,
+                             ExpectedHash, MetaIndexParser,
+                              ServerSha1, available_patches);
         return Finish();
       } else 
         return Finish(true);
@@ -792,22 +797,24 @@ void pkgAcqIndexDiffs::Done(string Message,unsigned long long Size,string Md5Has
                                                                        /*}}}*/
 // AcqIndexMergeDiffs::AcqIndexMergeDiffs - Constructor                        /*{{{*/
 pkgAcqIndexMergeDiffs::pkgAcqIndexMergeDiffs(pkgAcquire *Owner,
-                                  string const &URI, string const &URIDesc,
-                                  string const &ShortDesc, HashString const &ExpectedHash,
-                                  DiffInfo const &patch,
-                                  std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches)
-   : Item(Owner), RealURI(URI), ExpectedHash(ExpectedHash),
-     patch(patch),allPatches(allPatches), State(StateFetchDiff)
+                                             struct IndexTarget const * const Target,
+                                             HashString ExpectedHash,
+                                             indexRecords *MetaIndexParser,
+                                             DiffInfo const &patch,
+                                             std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches)
+   : pkgAcqBaseIndex(Owner, Target, ExpectedHash, MetaIndexParser),
+     patch(patch), allPatches(allPatches), State(StateFetchDiff)
 {
 
    DestFile = _config->FindDir("Dir::State::lists") + "partial/";
-   DestFile += URItoFileName(URI);
+   DestFile += URItoFileName(Target->URI);
 
    Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
 
-   Description = URIDesc;
+   RealURI = Target->URI;
    Desc.Owner = this;
-   Desc.ShortDesc = ShortDesc;
+   Description = Target->Description;
+   Desc.ShortDesc = Target->ShortDesc;
 
    Desc.URI = RealURI + ".diff/" + patch.file + ".gz";
    Desc.Description = Description + " " + patch.file + string(".pdiff");
@@ -838,8 +845,7 @@ void pkgAcqIndexMergeDiffs::Failed(string Message,pkgAcquire::MethodConfig * /*C
    // first failure means we should fallback
    State = StateErrorDiff;
    std::clog << "Falling back to normal index file acquire" << std::endl;
-   new pkgAcqIndex(Owner, RealURI, Description,Desc.ShortDesc,
-                  ExpectedHash);
+   new pkgAcqIndex(Owner, Target, ExpectedHash, MetaIndexParser);
 }
                                                                        /*}}}*/
 void pkgAcqIndexMergeDiffs::Done(string Message,unsigned long long Size,string Md5Hash,        /*{{{*/
@@ -922,8 +928,7 @@ void pkgAcqIndexMergeDiffs::Done(string Message,unsigned long long Size,string M
 pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner,
                         string URI,string URIDesc,string ShortDesc,
                         HashString ExpectedHash, string comprExt)
-   : Item(Owner), RealURI(URI), ExpectedHash(ExpectedHash), Target(0),
-     MetaIndexParser(0)
+   : pkgAcqBaseIndex(Owner, NULL, ExpectedHash, NULL), RealURI(URI)
 {
    if(comprExt.empty() == true)
    {
@@ -942,7 +947,8 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner,
 }
 pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner, IndexTarget const *Target,
                         HashString const &ExpectedHash, indexRecords *MetaIndexParser)
-   : Item(Owner), RealURI(Target->URI), ExpectedHash(ExpectedHash)
+   : pkgAcqBaseIndex(Owner, Target, ExpectedHash, MetaIndexParser), 
+     RealURI(Target->URI)
 {
    // autoselect the compression method
    std::vector<std::string> types = APT::Configuration::getCompressionTypes();
@@ -968,10 +974,6 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner, IndexTarget const *Target,
    else
      Verify = true;
 
-   // we need this in Init()
-   this->Target = Target;
-   this->MetaIndexParser = MetaIndexParser;
-
    Init(Target->URI, Target->Description, Target->ShortDesc);
 }
                                                                        /*}}}*/