From c045cc0268d70eb3b7c41076ade7381f73e740f2 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 29 Sep 2014 10:43:00 +0200 Subject: [PATCH] refactor --- apt-pkg/acquire-item.cc | 21 +++++++++--------- apt-pkg/acquire-item.h | 49 ++++++++++++++++++----------------------- 2 files changed, 33 insertions(+), 37 deletions(-) diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index d6b00f9b7..bfa0eb4fc 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -1470,10 +1470,10 @@ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner, /*{{{*/ string MetaIndexFile, const vector* IndexTargets, indexRecords* MetaIndexParser) : - pkgAcqMetaBase(Owner, HashStringList(), TransactionManager), RealURI(URI), - MetaIndexParser(MetaIndexParser), MetaIndexFile(MetaIndexFile), - URIDesc(URIDesc), ShortDesc(ShortDesc), - IndexTargets(IndexTargets), AuthPass(false), IMSHit(false) + pkgAcqMetaBase(Owner, IndexTargets, MetaIndexParser, + HashStringList(), TransactionManager), + RealURI(URI), MetaIndexFile(MetaIndexFile), URIDesc(URIDesc), + ShortDesc(ShortDesc), AuthPass(false), IMSHit(false) { DestFile = _config->FindDir("Dir::State::lists") + "partial/"; DestFile += URItoFileName(URI); @@ -1577,7 +1577,7 @@ void pkgAcqMetaSig::Done(string Message,unsigned long long Size, HashStringList { // load indexes and queue further downloads MetaIndexParser->Load(MetaIndexFile); - ((pkgAcqMetaIndex*)TransactionManager)->QueueIndexes(true); + QueueIndexes(true); } Complete = true; @@ -1622,7 +1622,7 @@ void pkgAcqMetaSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf)/*{{{*/ // we parse the indexes here because at this point the user wanted // a repository that may potentially harm him MetaIndexParser->Load(MetaIndexFile); - ((pkgAcqMetaIndex*)TransactionManager)->QueueIndexes(true); + QueueIndexes(true); } else { @@ -1648,9 +1648,10 @@ pkgAcqMetaIndex::pkgAcqMetaIndex(pkgAcquire *Owner, /*{{{*/ string MetaIndexSigURI,string MetaIndexSigURIDesc, string MetaIndexSigShortDesc, const vector* IndexTargets, indexRecords* MetaIndexParser) : - pkgAcqMetaBase(Owner, HashStringList(), TransactionManager), RealURI(URI), IndexTargets(IndexTargets), - URIDesc(URIDesc), ShortDesc(ShortDesc), - MetaIndexParser(MetaIndexParser), AuthPass(false), IMSHit(false), + pkgAcqMetaBase(Owner, IndexTargets, MetaIndexParser, HashStringList(), + TransactionManager), + RealURI(URI), URIDesc(URIDesc), ShortDesc(ShortDesc), + AuthPass(false), IMSHit(false), MetaIndexSigURI(MetaIndexSigURI), MetaIndexSigURIDesc(MetaIndexSigURIDesc), MetaIndexSigShortDesc(MetaIndexSigShortDesc) { @@ -1881,7 +1882,7 @@ void pkgAcqMetaIndex::AuthDone(string Message) /*{{{*/ #endif } /*}}}*/ -void pkgAcqMetaIndex::QueueIndexes(bool verify) /*{{{*/ +void pkgAcqMetaBase::QueueIndexes(bool verify) /*{{{*/ { bool transInRelease = false; { diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index e6a22ce7b..3c81f77a9 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -356,6 +356,24 @@ class pkgAcqMetaBase : public pkgAcquire::Item protected: std::vector Transaction; + /** \brief A package-system-specific parser for the meta-index file. */ + indexRecords *MetaIndexParser; + + /** \brief The index files which should be looked up in the meta-index + * and then downloaded. + */ + const std::vector* IndexTargets; + + /** \brief Starts downloading the individual index files. + * + * \param verify If \b true, only indices whose expected hashsum + * can be determined from the meta-index will be downloaded, and + * the hashsums of indices will be checked (reporting + * #StatAuthError if there is a mismatch). If verify is \b false, + * no hashsum checking will be performed. + */ + void QueueIndexes(bool verify); + public: // transaction code void Add(Item *I); @@ -369,9 +387,12 @@ class pkgAcqMetaBase : public pkgAcquire::Item pkgAcqMetaBase(pkgAcquire *Owner, + const std::vector* IndexTargets, + indexRecords* MetaIndexParser, HashStringList const &ExpectedHashes=HashStringList(), pkgAcqMetaBase *TransactionManager=NULL) - : Item(Owner, ExpectedHashes, TransactionManager) {}; + : Item(Owner, ExpectedHashes, TransactionManager), + MetaIndexParser(MetaIndexParser), IndexTargets(IndexTargets) {}; }; /** \brief An acquire item that downloads the detached signature {{{ @@ -397,19 +418,9 @@ class pkgAcqMetaSig : public pkgAcqMetaBase std::string URIDesc; std::string ShortDesc; - /** \brief A package-system-specific parser for the meta-index file. */ - indexRecords* MetaIndexParser; - /** \brief The file we need to verify */ std::string MetaIndexFile; - /** \brief The index files which should be looked up in the meta-index - * and then downloaded. - * - * \todo Why a list of pointers instead of a list of structs? - */ - const std::vector* IndexTargets; - /** \brief If we are in fetching or download state */ bool AuthPass; @@ -463,12 +474,6 @@ class pkgAcqMetaIndex : public pkgAcqMetaBase */ std::string SigFile; - /** \brief The index files to download. */ - const std::vector* IndexTargets; - - /** \brief The parser for the meta-index file. */ - indexRecords* MetaIndexParser; - /** \brief If \b true, the index's signature is currently being verified. */ bool AuthPass; @@ -521,16 +526,6 @@ class pkgAcqMetaIndex : public pkgAcqMetaBase public: - /** \brief Starts downloading the individual index files. - * - * \param verify If \b true, only indices whose expected hashsum - * can be determined from the meta-index will be downloaded, and - * the hashsums of indices will be checked (reporting - * #StatAuthError if there is a mismatch). If verify is \b false, - * no hashsum checking will be performed. - */ - void QueueIndexes(bool verify); - // Specialized action members virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, -- 2.45.2