diff options
author | David Kalnischkies <david@kalnischkies.de> | 2015-04-12 14:32:12 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2015-04-19 01:13:09 +0200 |
commit | 295d848b37e1211feae5d37db27f148dc9ea3d38 (patch) | |
tree | 88927494207c7596ad8a6069ce16def3ce7ffc28 /apt-pkg | |
parent | de1c9b8ad208ae677fc6e916a907e319f246b1e8 (diff) |
refactor calculation of final lists/ name from URI
Calculating the final name of an item which it will have after
everything is done and verified successfully is suprisingly complicated
as while they all follow a simple pattern, the URI and where it is
stored varies between the items.
With some (abibreaking) redesign we can abstract this similar to how it
is already down for the partial file location.
Git-Dch: Ignore
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/acquire-item.cc | 193 | ||||
-rw-r--r-- | apt-pkg/acquire-item.h | 83 |
2 files changed, 124 insertions, 152 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index bdbdcc456..f30529066 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -74,6 +74,11 @@ static std::string GetPartialFileNameFromURI(std::string const &uri) /*{{{*/ return GetPartialFileName(URItoFileName(uri)); } /*}}}*/ +static std::string GetFinalFileNameFromURI(std::string const &uri) /*{{{*/ +{ + return _config->FindDir("Dir::State::lists") + URItoFileName(uri); +} + /*}}}*/ static std::string GetCompressedFileName(std::string const &URI, std::string const &Name, std::string const &Ext) /*{{{*/ { if (Ext.empty() || Ext == "uncompressed") @@ -273,6 +278,12 @@ void pkgAcquire::Item::SetActiveSubprocess(const std::string &subprocess)/*{{{*/ APT_IGNORE_DEPRECATED(Mode = ActiveSubprocess.c_str();) } /*}}}*/ +// Acquire::Item::GetFinalFilename - Return the full final file path /*{{{*/ +std::string pkgAcquire::Item::GetFinalFilename() const +{ + return GetFinalFileNameFromURI(Desc.URI); +} + /*}}}*/ // Acquire::Item::ReportMirrorFailure /*{{{*/ // --------------------------------------------------------------------- void pkgAcquire::Item::ReportMirrorFailure(string FailCode) @@ -348,8 +359,7 @@ pkgAcqDiffIndex::pkgAcqDiffIndex(pkgAcquire *Owner, std::clog << "pkgAcqDiffIndex: " << Desc.URI << std::endl; // look for the current package file - CurrentPackagesFile = _config->FindDir("Dir::State::lists"); - CurrentPackagesFile += URItoFileName(RealURI); + CurrentPackagesFile = GetFinalFileNameFromURI(RealURI); // FIXME: this file:/ check is a hack to prevent fetching // from local sources. this is really silly, and @@ -370,6 +380,13 @@ pkgAcqDiffIndex::pkgAcqDiffIndex(pkgAcquire *Owner, } /*}}}*/ +// Acquire::Item::GetFinalFilename - Return the full final file path /*{{{*/ +std::string pkgAcqDiffIndex::GetFinalFilename() const +{ + // the logic we inherent from pkgAcqBaseIndex isn't what we need here + return pkgAcquire::Item::GetFinalFilename(); +} + /*}}}*/ // AcqIndex::Custom600Headers - Insert custom request headers /*{{{*/ // --------------------------------------------------------------------- /* The only header we use is the last-modified header. */ @@ -379,8 +396,7 @@ string pkgAcqDiffIndex::Custom600Headers() const string pkgAcqDiffIndex::Custom600Headers() #endif { - string Final = _config->FindDir("Dir::State::lists"); - Final += URItoFileName(Desc.URI); + string const Final = GetFinalFilename(); if(Debug) std::clog << "Custom600Header-IMS: " << Final << std::endl; @@ -709,10 +725,7 @@ void pkgAcqDiffIndex::Done(string Message,unsigned long long Size,HashStringList } - string FinalFile; - FinalFile = _config->FindDir("Dir::State::lists"); - FinalFile += URItoFileName(Desc.URI); - + string const FinalFile = GetFinalFilename(); if(StringToBool(LookupTag(Message,"IMS-Hit"),false)) DestFile = FinalFile; @@ -754,8 +767,7 @@ pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire *Owner, if(available_patches.empty() == true) { // we are done (yeah!), check hashes against the final file - DestFile = _config->FindDir("Dir::State::lists"); - DestFile += URItoFileName(Target->URI); + DestFile = GetFinalFileNameFromURI(Target->URI); Finish(true); } else @@ -797,10 +809,7 @@ void pkgAcqIndexDiffs::Finish(bool allDone) return; } - // queue for copy - std::string FinalFile = _config->FindDir("Dir::State::lists"); - FinalFile += URItoFileName(RealURI); - TransactionManager->TransactionStageCopy(this, DestFile, FinalFile); + TransactionManager->TransactionStageCopy(this, DestFile, GetFinalFilename()); // this is for the "real" finish Complete = true; @@ -1064,10 +1073,8 @@ void pkgAcqIndexMergeDiffs::Done(string Message,unsigned long long Size,HashStri } - std::string FinalFile = _config->FindDir("Dir::State::lists"); - FinalFile += URItoFileName(RealURI); - // move the result into place + std::string const FinalFile = GetFinalFilename(); if(Debug) std::clog << "Queue patched file in place: " << std::endl << DestFile << " -> " << FinalFile << std::endl; @@ -1106,6 +1113,12 @@ bool pkgAcqBaseIndex::VerifyHashByMetaKey(HashStringList const &Hashes) return true; } /*}}}*/ +// AcqBaseIndex::GetFinalFilename - Return the full final file path /*{{{*/ +std::string pkgAcqBaseIndex::GetFinalFilename() const +{ + return GetFinalFileNameFromURI(RealURI); +} + /*}}}*/ // AcqIndex::AcqIndex - Constructor /*{{{*/ // --------------------------------------------------------------------- /* The package file is added to the queue and a second class is @@ -1293,8 +1306,7 @@ void pkgAcqIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf) // pkgAcqIndex::GetFinalFilename - Return the full final file path /*{{{*/ std::string pkgAcqIndex::GetFinalFilename() const { - std::string FinalFile = _config->FindDir("Dir::State::lists"); - FinalFile += URItoFileName(RealURI); + std::string const FinalFile = GetFinalFileNameFromURI(RealURI); return GetCompressedFileName(RealURI, FinalFile, CurrentCompressionExtension); } /*}}}*/ @@ -1566,18 +1578,16 @@ void pkgAcqMetaBase::TransactionStageRemoval(Item *I, const std::string &FinalFile) { I->PartialFile = ""; - I->DestFile = FinalFile; + I->DestFile = FinalFile; } /*}}}*/ // AcqMetaBase::GenerateAuthWarning - Check gpg authentication error /*{{{*/ -bool pkgAcqMetaBase::CheckStopAuthentication(const std::string &RealURI, - const std::string &Message) +bool pkgAcqMetaBase::CheckStopAuthentication(const std::string &Message) { // FIXME: this entire function can do now that we disallow going to // a unauthenticated state and can cleanly rollback - string Final = _config->FindDir("Dir::State::lists") + URItoFileName(RealURI); - + string const Final = GetFinalFilename(); if(FileExists(Final)) { Status = StatTransientNetworkError; @@ -1613,13 +1623,12 @@ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner, string MetaIndexFile, const vector<IndexTarget*>* IndexTargets, indexRecords* MetaIndexParser) : - pkgAcqMetaBase(Owner, IndexTargets, MetaIndexParser, + pkgAcqMetaBase(Owner, IndexTargets, MetaIndexParser, URI, HashStringList(), TransactionManager), - RealURI(URI), MetaIndexFile(MetaIndexFile), URIDesc(URIDesc), + MetaIndexFile(MetaIndexFile), URIDesc(URIDesc), ShortDesc(ShortDesc) { - DestFile = _config->FindDir("Dir::State::lists") + "partial/"; - DestFile += URItoFileName(RealURI); + DestFile = GetPartialFileNameFromURI(RealURI); // remove any partial downloaded sig-file in partial/. // it may confuse proxies and is too small to warrant a @@ -1644,18 +1653,6 @@ pkgAcqMetaSig::~pkgAcqMetaSig() /*{{{*/ { } /*}}}*/ -// pkgAcqMetaSig::Custom600Headers - Insert custom request headers /*{{{*/ -// --------------------------------------------------------------------- -#if APT_PKG_ABI >= 413 -string pkgAcqMetaSig::Custom600Headers() const -#else -string pkgAcqMetaSig::Custom600Headers() -#endif -{ - std::string Header = GetCustom600Headers(RealURI); - return Header; -} - /*}}}*/ // pkgAcqMetaSig::Done - The signature was downloaded/verified /*{{{*/ // --------------------------------------------------------------------- /* The only header we use is the last-modified header. */ @@ -1667,7 +1664,7 @@ void pkgAcqMetaSig::Done(string Message,unsigned long long Size, if(AuthPass == false) { - if(CheckDownloadDone(Message, RealURI) == true) + if(CheckDownloadDone(Message) == true) { // destfile will be modified to point to MetaIndexFile for the // gpgv method, so we need to save it here @@ -1676,15 +1673,8 @@ void pkgAcqMetaSig::Done(string Message,unsigned long long Size, } return; } - else - { - if(CheckAuthDone(Message, RealURI) == true) - { - std::string FinalFile = _config->FindDir("Dir::State::lists"); - FinalFile += URItoFileName(RealURI); - TransactionManager->TransactionStageCopy(this, MetaIndexFileSignature, FinalFile); - } - } + else if(CheckAuthDone(Message) == true) + TransactionManager->TransactionStageCopy(this, MetaIndexFileSignature, GetFinalFilename()); } /*}}}*/ void pkgAcqMetaSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf)/*{{{*/ @@ -1692,14 +1682,14 @@ void pkgAcqMetaSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf)/*{{{*/ Item::Failed(Message,Cnf); // check if we need to fail at this point - if (AuthPass == true && CheckStopAuthentication(RealURI, Message)) + if (AuthPass == true && CheckStopAuthentication(Message)) return; // FIXME: meh, this is not really elegant - string const Final = _config->FindDir("Dir::State::lists") + URItoFileName(RealURI); + string const Final = GetFinalFileNameFromURI(RealURI); string const InReleaseURI = RealURI.replace(RealURI.rfind("Release.gpg"), 12, "InRelease"); - string const FinalInRelease = _config->FindDir("Dir::State::lists") + URItoFileName(InReleaseURI); + string const FinalInRelease = GetFinalFileNameFromURI(InReleaseURI); if (RealFileExists(Final) || RealFileExists(FinalInRelease)) { @@ -1739,7 +1729,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); - if (!VerifyVendor(Message, RealURI)) + if (!VerifyVendor(Message)) /* expired Release files are still a problem you need extra force for */; else QueueIndexes(true); @@ -1760,9 +1750,9 @@ pkgAcqMetaIndex::pkgAcqMetaIndex(pkgAcquire *Owner, /*{{{*/ string MetaIndexSigURI,string MetaIndexSigURIDesc, string MetaIndexSigShortDesc, const vector<IndexTarget*>* IndexTargets, indexRecords* MetaIndexParser) : - pkgAcqMetaBase(Owner, IndexTargets, MetaIndexParser, HashStringList(), + pkgAcqMetaBase(Owner, IndexTargets, MetaIndexParser, URI, HashStringList(), TransactionManager), - RealURI(URI), URIDesc(URIDesc), ShortDesc(ShortDesc), + URIDesc(URIDesc), ShortDesc(ShortDesc), MetaIndexSigURI(MetaIndexSigURI), MetaIndexSigURIDesc(MetaIndexSigURIDesc), MetaIndexSigShortDesc(MetaIndexSigShortDesc) { @@ -1796,24 +1786,13 @@ void pkgAcqMetaIndex::Init(std::string URIDesc, std::string ShortDesc) QueueURI(Desc); } /*}}}*/ -// pkgAcqMetaIndex::Custom600Headers - Insert custom request headers /*{{{*/ -// --------------------------------------------------------------------- -#if APT_PKG_ABI >= 413 -string pkgAcqMetaIndex::Custom600Headers() const -#else -string pkgAcqMetaIndex::Custom600Headers() -#endif -{ - return GetCustom600Headers(RealURI); -} - /*}}}*/ void pkgAcqMetaIndex::Done(string Message,unsigned long long Size, /*{{{*/ HashStringList const &Hashes, pkgAcquire::MethodConfig *Cfg) { Item::Done(Message,Size,Hashes,Cfg); - if(CheckDownloadDone(Message, RealURI)) + if(CheckDownloadDone(Message)) { // we have a Release file, now download the Signature, all further // verify/queue for additional downloads will be done in the @@ -1824,13 +1803,11 @@ void pkgAcqMetaIndex::Done(string Message,unsigned long long Size, /*{{{*/ MetaIndexSigShortDesc, MetaIndexFile, IndexTargets, MetaIndexParser); - string FinalFile = _config->FindDir("Dir::State::lists"); - FinalFile += URItoFileName(RealURI); - TransactionManager->TransactionStageCopy(this, DestFile, FinalFile); + TransactionManager->TransactionStageCopy(this, DestFile, GetFinalFilename()); } } /*}}}*/ -bool pkgAcqMetaBase::CheckAuthDone(string Message, const string &RealURI) /*{{{*/ +bool pkgAcqMetaBase::CheckAuthDone(string Message) /*{{{*/ { // At this point, the gpgv method has succeeded, so there is a // valid signature from a key in the trusted keyring. We @@ -1844,7 +1821,7 @@ bool pkgAcqMetaBase::CheckAuthDone(string Message, const string &RealURI) /*{{{* return false; } - if (!VerifyVendor(Message, RealURI)) + if (!VerifyVendor(Message)) { Status = StatAuthError; return false; @@ -1866,9 +1843,13 @@ bool pkgAcqMetaBase::CheckAuthDone(string Message, const string &RealURI) /*{{{* return true; } /*}}}*/ -// pkgAcqMetaBase::GetCustom600Headers - Get header for AcqMetaBase /*{{{*/ +// pkgAcqMetaBase::Custom600Headers - Get header for AcqMetaBase /*{{{*/ // --------------------------------------------------------------------- -string pkgAcqMetaBase::GetCustom600Headers(const string &RealURI) const +#if APT_PKG_ABI >= 413 +string pkgAcqMetaBase::Custom600Headers() const +#else +string pkgAcqMetaBase::Custom600Headers() +#endif { std::string Header = "\nIndex-File: true"; std::string MaximumSize; @@ -1876,8 +1857,7 @@ string pkgAcqMetaBase::GetCustom600Headers(const string &RealURI) const _config->FindI("Acquire::MaxReleaseFileSize", 10*1000*1000)); Header += MaximumSize; - string FinalFile = _config->FindDir("Dir::State::lists"); - FinalFile += URItoFileName(RealURI); + string const FinalFile = GetFinalFilename(); struct stat Buf; if (stat(FinalFile.c_str(),&Buf) == 0) @@ -1886,6 +1866,12 @@ string pkgAcqMetaBase::GetCustom600Headers(const string &RealURI) const return Header; } /*}}}*/ +// pkgAcqMetaBase::GetFinalFilename - Return the full final file path /*{{{*/ +std::string pkgAcqMetaBase::GetFinalFilename() const +{ + return GetFinalFileNameFromURI(RealURI); +} + /*}}}*/ // pkgAcqMetaBase::QueueForSignatureVerify /*{{{*/ void pkgAcqMetaBase::QueueForSignatureVerify(const std::string &MetaIndexFile, const std::string &MetaIndexFileSignature) @@ -1898,8 +1884,7 @@ void pkgAcqMetaBase::QueueForSignatureVerify(const std::string &MetaIndexFile, } /*}}}*/ // pkgAcqMetaBase::CheckDownloadDone /*{{{*/ -bool pkgAcqMetaBase::CheckDownloadDone(const std::string &Message, - const std::string &RealURI) +bool pkgAcqMetaBase::CheckDownloadDone(const std::string &Message) { // We have just finished downloading a Release file (it is not // verified yet) @@ -1923,11 +1908,7 @@ bool pkgAcqMetaBase::CheckDownloadDone(const std::string &Message, // make sure to verify against the right file on I-M-S hit IMSHit = StringToBool(LookupTag(Message,"IMS-Hit"),false); if(IMSHit) - { - string FinalFile = _config->FindDir("Dir::State::lists"); - FinalFile += URItoFileName(RealURI); - DestFile = FinalFile; - } + DestFile = GetFinalFilename(); // set Item to complete as the remaining work is all local (verify etc) Complete = true; @@ -1993,7 +1974,7 @@ void pkgAcqMetaBase::QueueIndexes(bool verify) /*{{{*/ } } /*}}}*/ -bool pkgAcqMetaBase::VerifyVendor(string Message, const string &RealURI)/*{{{*/ +bool pkgAcqMetaBase::VerifyVendor(string Message) /*{{{*/ { string::size_type pos; @@ -2083,8 +2064,6 @@ void pkgAcqMetaIndex::Failed(string Message, pkgAcquire::Item::Failed(Message, Cnf); Status = StatDone; - string FinalFile = _config->FindDir("Dir::State::lists") + URItoFileName(RealURI); - _error->Warning(_("The repository '%s' does not have a Release file. " "This is deprecated, please contact the owner of the " "repository."), URIDesc.c_str()); @@ -2096,7 +2075,7 @@ void pkgAcqMetaIndex::Failed(string Message, { // Done, queue for rename on transaction finished if (FileExists(DestFile)) - TransactionManager->TransactionStageCopy(this, DestFile, FinalFile); + TransactionManager->TransactionStageCopy(this, DestFile, GetFinalFilename()); // queue without any kind of hashsum support QueueIndexes(false); @@ -2132,19 +2111,18 @@ pkgAcqMetaClearSig::~pkgAcqMetaClearSig() /*{{{*/ } /*}}}*/ // pkgAcqMetaClearSig::Custom600Headers - Insert custom request headers /*{{{*/ -// --------------------------------------------------------------------- #if APT_PKG_ABI >= 413 string pkgAcqMetaClearSig::Custom600Headers() const #else string pkgAcqMetaClearSig::Custom600Headers() #endif { - string Header = GetCustom600Headers(RealURI); + string Header = pkgAcqMetaBase::Custom600Headers(); Header += "\nFail-Ignore: true"; return Header; } /*}}}*/ -// pkgAcqMetaClearSig::Done - We got a file /*{{{*/ +// pkgAcqMetaClearSig::Done - We got a file /*{{{*/ // --------------------------------------------------------------------- void pkgAcqMetaClearSig::Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, @@ -2165,21 +2143,12 @@ void pkgAcqMetaClearSig::Done(std::string Message,unsigned long long Size, if(AuthPass == false) { - if(CheckDownloadDone(Message, RealURI) == true) + if(CheckDownloadDone(Message) == true) QueueForSignatureVerify(DestFile, DestFile); return; } - else - { - if(CheckAuthDone(Message, RealURI) == true) - { - string FinalFile = _config->FindDir("Dir::State::lists"); - FinalFile += URItoFileName(RealURI); - - // queue for copy in place - TransactionManager->TransactionStageCopy(this, DestFile, FinalFile); - } - } + else if(CheckAuthDone(Message) == true) + TransactionManager->TransactionStageCopy(this, DestFile, GetFinalFilename()); } /*}}}*/ void pkgAcqMetaClearSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf) /*{{{*/ @@ -2194,9 +2163,7 @@ void pkgAcqMetaClearSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf) /* // Queue the 'old' InRelease file for removal if we try Release.gpg // as otherwise the file will stay around and gives a false-auth // impression (CVE-2012-0214) - string FinalFile = _config->FindDir("Dir::State::lists"); - FinalFile.append(URItoFileName(RealURI)); - TransactionManager->TransactionStageRemoval(this, FinalFile); + TransactionManager->TransactionStageRemoval(this, GetFinalFilename()); Status = StatDone; new pkgAcqMetaIndex(Owner, TransactionManager, @@ -2206,7 +2173,7 @@ void pkgAcqMetaClearSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf) /* } else { - if(CheckStopAuthentication(RealURI, Message)) + if(CheckStopAuthentication(Message)) return; _error->Warning(_("The data from '%s' is not signed. Packages " @@ -2224,8 +2191,7 @@ void pkgAcqMetaClearSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf) /* * that PackageFile objects are correctly filled in */ if (FileExists(DestFile)) { - string FinalFile = _config->FindDir("Dir::State::lists"); - FinalFile += URItoFileName(RealURI); + string FinalFile = GetFinalFilename(); /* InRelease files become Release files, otherwise * they would be considered as trusted later on */ RealURI = RealURI.replace(RealURI.rfind("InRelease"), 9, @@ -2482,13 +2448,18 @@ void pkgAcqArchive::Done(string Message,unsigned long long Size, HashStringList } // Done, move it into position - string FinalFile = _config->FindDir("Dir::Cache::Archives"); - FinalFile += flNotDir(StoreFilename); + string const FinalFile = GetFinalFilename(); Rename(DestFile,FinalFile); StoreFilename = DestFile = FinalFile; Complete = true; } /*}}}*/ +// Acquire::Item::GetFinalFilename - Return the full final file path /*{{{*/ +std::string pkgAcqArchive::GetFinalFilename() const +{ + return _config->FindDir("Dir::Cache::Archives") + flNotDir(StoreFilename); +} + /*}}}*/ // AcqArchive::Failed - Failure handler /*{{{*/ // --------------------------------------------------------------------- /* Here we try other sources */ diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 1af737e00..c2759b792 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -93,6 +93,9 @@ class pkgAcquire::Item : public WeakPointable */ bool Rename(std::string From,std::string To); + /** \brief Get the full pathname of the final file for the current URI */ + virtual std::string GetFinalFilename() const; + public: /** \brief The current status of this item. */ @@ -390,7 +393,13 @@ class pkgAcqMetaBase : public pkgAcquire::Item /*{{{*/ bool AuthPass; // required to deal gracefully with problems caused by incorrect ims hits - bool IMSHit; + bool IMSHit; + + /** \brief The URI of the signature file. Unlike Desc.URI, this is + * never modified; it is used to determine the file that is being + * downloaded. + */ + std::string RealURI; /** \brief Starts downloading the individual index files. * @@ -411,15 +420,17 @@ class pkgAcqMetaBase : public pkgAcquire::Item /*{{{*/ * \param Message The message block received from the fetch * subprocess. */ - bool CheckDownloadDone(const std::string &Message, - const std::string &RealURI); + bool CheckDownloadDone(const std::string &Message); /** \brief Queue the downloaded Signature for verification */ void QueueForSignatureVerify(const std::string &MetaIndexFile, const std::string &MetaIndexFileSignature); - /** \brief get the custom600 header for all pkgAcqMeta */ - std::string GetCustom600Headers(const std::string &RealURI) const; +#if APT_PKG_ABI >= 413 + virtual std::string Custom600Headers() const; +#else + virtual std::string Custom600Headers(); +#endif /** \brief Called when authentication succeeded. * @@ -430,20 +441,24 @@ class pkgAcqMetaBase : public pkgAcquire::Item /*{{{*/ * \param Message The message block received from the fetch * subprocess. */ - bool CheckAuthDone(std::string Message, const std::string &RealURI); + bool CheckAuthDone(std::string Message); /** Check if the current item should fail at this point */ - bool CheckStopAuthentication(const std::string &RealURI, - const std::string &Message); + bool CheckStopAuthentication(const std::string &Message); /** \brief Check that the release file is a release file for the * correct distribution. * * \return \b true if no fatal errors were encountered. */ - bool VerifyVendor(std::string Message, const std::string &RealURI); - + bool VerifyVendor(std::string Message); + + /** \brief Get the full pathname of the final file for the current URI */ + virtual std::string GetFinalFilename() const; + public: + virtual std::string DescURI() {return RealURI; }; + // transaction code void Add(Item *I); void AbortTransaction(); @@ -462,11 +477,12 @@ class pkgAcqMetaBase : public pkgAcquire::Item /*{{{*/ pkgAcqMetaBase(pkgAcquire *Owner, const std::vector<IndexTarget*>* IndexTargets, indexRecords* MetaIndexParser, + std::string const &RealURI, HashStringList const &ExpectedHashes=HashStringList(), pkgAcqMetaBase *TransactionManager=NULL) : Item(Owner, ExpectedHashes, TransactionManager), MetaIndexParser(MetaIndexParser), IndexTargets(IndexTargets), - AuthPass(false), IMSHit(false) {}; + AuthPass(false), IMSHit(false), RealURI(RealURI) {}; }; /*}}}*/ /** \brief An acquire item that downloads the detached signature {{{ @@ -483,12 +499,6 @@ class APT_HIDDEN pkgAcqMetaSig : public pkgAcqMetaBase protected: - /** \brief The URI of the signature file. Unlike Desc.URI, this is - * never modified; it is used to determine the file that is being - * downloaded. - */ - std::string RealURI; - /** \brief The file we need to verify */ std::string MetaIndexFile; @@ -502,18 +512,12 @@ class APT_HIDDEN pkgAcqMetaSig : public pkgAcqMetaBase std::string ShortDesc; public: - + // 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, pkgAcquire::MethodConfig *Cnf); -#if APT_PKG_ABI >= 413 - virtual std::string Custom600Headers() const; -#else - virtual std::string Custom600Headers(); -#endif - virtual std::string DescURI() {return RealURI; }; /** \brief Create a new pkgAcqMetaSig. */ pkgAcqMetaSig(pkgAcquire *Owner, @@ -540,11 +544,6 @@ class APT_HIDDEN pkgAcqMetaIndex : public pkgAcqMetaBase void *d; protected: - /** \brief The URI that is actually being downloaded; never - * modified by pkgAcqMetaIndex. - */ - std::string RealURI; - std::string URIDesc; std::string ShortDesc; @@ -566,12 +565,6 @@ class APT_HIDDEN pkgAcqMetaIndex : public pkgAcqMetaBase virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, pkgAcquire::MethodConfig *Cnf); -#if APT_PKG_ABI >= 413 - virtual std::string Custom600Headers() const; -#else - virtual std::string Custom600Headers(); -#endif - virtual std::string DescURI() {return RealURI; }; virtual void Finished(); /** \brief Create a new pkgAcqMetaIndex. */ @@ -652,6 +645,9 @@ class pkgAcqBaseIndex : public pkgAcquire::Item bool VerifyHashByMetaKey(HashStringList const &Hashes); + /** \brief Get the full pathname of the final file for the current URI */ + virtual std::string GetFinalFilename() const; + pkgAcqBaseIndex(pkgAcquire *Owner, pkgAcqMetaBase *TransactionManager, struct IndexTarget const * const Target, @@ -692,6 +688,9 @@ class APT_HIDDEN pkgAcqDiffIndex : public pkgAcqBaseIndex */ bool PackagesFileReadyInPartial; + /** \brief Get the full pathname of the final file for the current URI */ + virtual std::string GetFinalFilename() const; + public: // Specialized action members virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); @@ -999,16 +998,15 @@ class APT_HIDDEN pkgAcqIndex : public pkgAcqBaseIndex /** \brief Auto select the right compression to use */ void AutoSelectCompression(); - /** \brief Get the full pathname of the final file for the current URI - */ - std::string GetFinalFilename() const; - /** \brief Schedule file for verification after a IMS hit */ void ReverifyAfterIMS(); /** \brief Validate the downloaded index file */ bool ValidateFile(const std::string &FileName); + /** \brief Get the full pathname of the final file for the current URI */ + virtual std::string GetFinalFilename() const; + public: // Specialized action members @@ -1133,9 +1131,12 @@ class pkgAcqArchive : public pkgAcquire::Item /** \brief Queue up the next available file for this version. */ bool QueueNext(); - + + /** \brief Get the full pathname of the final file for the current URI */ + virtual std::string GetFinalFilename() const; + public: - + virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes, pkgAcquire::MethodConfig *Cnf); |