]> git.saurik.com Git - apt.git/commitdiff
Add new pkgAcqBaseIndex as base class for pkgAcq{DiffIndex,IndexMerge,pkgAcqBaseIndex...
authorMichael Vogt <mvo@ubuntu.com>
Wed, 14 May 2014 15:47:20 +0000 (17:47 +0200)
committerMichael Vogt <mvo@ubuntu.com>
Wed, 14 May 2014 15:47:20 +0000 (17:47 +0200)
apt-pkg/acquire-item.cc
apt-pkg/acquire-item.h

index 4d9f5cd00ca5a8adabca436a1fc3b07f1569c36e..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);
@@ -616,9 +614,8 @@ pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire *Owner,
                                    indexRecords *MetaIndexParser,
                                   string ServerSha1,
                                   vector<DiffInfo> diffs)
-   : Item(Owner), ExpectedHash(ExpectedHash),
-     available_patches(diffs), ServerSha1(ServerSha1), 
-     Target(Target), MetaIndexParser(MetaIndexParser)
+   : pkgAcqBaseIndex(Owner, Target, ExpectedHash, MetaIndexParser),
+     available_patches(diffs), ServerSha1(ServerSha1)
 {
    
    DestFile = _config->FindDir("Dir::State::lists") + "partial/";
@@ -805,9 +802,8 @@ pkgAcqIndexMergeDiffs::pkgAcqIndexMergeDiffs(pkgAcquire *Owner,
                                              indexRecords *MetaIndexParser,
                                              DiffInfo const &patch,
                                              std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches)
-   : Item(Owner), ExpectedHash(ExpectedHash), patch(patch),
-     allPatches(allPatches), State(StateFetchDiff), 
-     Target(Target), MetaIndexParser(MetaIndexParser)
+   : pkgAcqBaseIndex(Owner, Target, ExpectedHash, MetaIndexParser),
+     patch(patch), allPatches(allPatches), State(StateFetchDiff)
 {
 
    DestFile = _config->FindDir("Dir::State::lists") + "partial/";
@@ -932,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)
    {
@@ -952,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();
@@ -978,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);
 }
                                                                        /*}}}*/
index 7219e8047a117dab8130586ca1b6753135fa4c04..35cd78afcfa02b00d4a33a87590f162207d63213 100644 (file)
@@ -368,6 +368,9 @@ class pkgAcqSubIndex : public pkgAcquire::Item
 };
                                                                        /*}}}*/
 
+/** \brief Common base class for all classes that deal with fetching   {{{
+           indexes
+ */
 class pkgAcqBaseIndex : public pkgAcquire::Item
 {
  protected:
@@ -376,9 +379,18 @@ class pkgAcqBaseIndex : public pkgAcquire::Item
    const struct IndexTarget * Target;
    indexRecords *MetaIndexParser;
 
+   /** \brief The Hash that this file should have after download
+    */
+   HashString ExpectedHash;
 
+   pkgAcqBaseIndex(pkgAcquire *Owner,
+                   struct IndexTarget const * const Target,
+                   HashString ExpectedHash,
+                   indexRecords *MetaIndexParser)
+      : Item(Owner), Target(Target), MetaIndexParser(MetaIndexParser),
+        ExpectedHash(ExpectedHash) {};
 };
-
+                                                                       /*}}}*/
 /** \brief An item that is responsible for fetching an index file of   {{{
  *  package list diffs and starting the package list's download.
  *
@@ -388,7 +400,7 @@ class pkgAcqBaseIndex : public pkgAcquire::Item
  *
  *  \sa pkgAcqIndexDiffs, pkgAcqIndex
  */
-class pkgAcqDiffIndex : public pkgAcquire::Item
+class pkgAcqDiffIndex : public pkgAcqBaseIndex
 {
  protected:
    /** \brief If \b true, debugging information will be written to std::clog. */
@@ -402,11 +414,6 @@ class pkgAcqDiffIndex : public pkgAcquire::Item
     */
    std::string RealURI;
 
-   /** \brief The Hash that the real index file should have after
-    *  all patches have been applied.
-    */
-   HashString ExpectedHash;
-
    /** \brief The index file which will be patched to generate the new
     *  file.
     */
@@ -417,11 +424,6 @@ class pkgAcqDiffIndex : public pkgAcquire::Item
     */
    std::string Description;
 
-   /** \brief Pointer to the IndexTarget data
-    */
-   const struct IndexTarget * Target;
-   indexRecords *MetaIndexParser;
-
  public:
    // Specialized action members
    virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
@@ -472,7 +474,7 @@ class pkgAcqDiffIndex : public pkgAcquire::Item
  *
  *  \sa pkgAcqDiffIndex, pkgAcqIndex
  */
-class pkgAcqIndexMergeDiffs : public pkgAcquire::Item
+class pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex
 {
    protected:
 
@@ -491,11 +493,6 @@ class pkgAcqIndexMergeDiffs : public pkgAcquire::Item
     */
    std::string RealURI;
 
-   /** \brief HashSum of the package index file that is being
-    *  reconstructed.
-    */
-   HashString ExpectedHash;
-
    /** \brief description of the file being downloaded. */
    std::string Description;
 
@@ -521,11 +518,6 @@ class pkgAcqIndexMergeDiffs : public pkgAcquire::Item
       StateErrorDiff
    } State;
 
-   /** \brief Pointer to the IndexTarget data
-    */
-   const struct IndexTarget * Target;
-   indexRecords *MetaIndexParser;
-
    public:
    /** \brief Called when the patch file failed to be downloaded.
     *
@@ -578,7 +570,7 @@ class pkgAcqIndexMergeDiffs : public pkgAcquire::Item
  *
  *  \sa pkgAcqDiffIndex, pkgAcqIndex
  */
-class pkgAcqIndexDiffs : public pkgAcquire::Item
+class pkgAcqIndexDiffs : public pkgAcqBaseIndex
 {
    private:
 
@@ -623,11 +615,6 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item
     */
    std::string RealURI;
 
-   /** \brief The HashSum of the package index file that is being
-    *  reconstructed.
-    */
-   HashString ExpectedHash;
-
    /** A description of the file being downloaded. */
    std::string Description;
 
@@ -660,11 +647,6 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item
         StateApplyDiff
    } State;
 
-   /** \brief Pointer to the IndexTarget data
-    */
-   const struct IndexTarget * Target;
-   indexRecords *MetaIndexParser;
-
    public:
    
    /** \brief Called when the patch file failed to be downloaded.
@@ -717,7 +699,7 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item
  *
  *  \todo Why does pkgAcqIndex have protected members?
  */
-class pkgAcqIndex : public pkgAcquire::Item
+class pkgAcqIndex : public pkgAcqBaseIndex
 {
    protected:
 
@@ -749,19 +731,11 @@ class pkgAcqIndex : public pkgAcquire::Item
     */
    std::string RealURI;
 
-   /** \brief The expected hashsum of the decompressed index file. */
-   HashString ExpectedHash;
-
    /** \brief The compression-related file extensions that are being
     *  added to the downloaded file one by one if first fails (e.g., "gz bz2").
     */
    std::string CompressionExtension;
 
-   /** \brief Pointer to the IndexTarget data
-    */
-   const struct IndexTarget * Target;
-   indexRecords *MetaIndexParser;
-
    public:
    
    // Specialized action members
@@ -798,7 +772,8 @@ class pkgAcqIndex : public pkgAcquire::Item
                struct IndexTarget const * const Target,
                HashString const &ExpectedHash,
                indexRecords *MetaIndexParser);
-   void Init(std::string const &URI, std::string const &URIDesc, std::string const &ShortDesc);
+   void Init(std::string const &URI, std::string const &URIDesc,
+             std::string const &ShortDesc);
 };
                                                                        /*}}}*/
 /** \brief An acquire item that is responsible for fetching a          {{{