From e1430400bf012ab7e29b00c78796a14ce9f97107 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 29 May 2010 12:04:51 +0200 Subject: * apt-pkg/indexrecords.{cc,h}: - add a constant Exists check for MetaKeys * apt-pkg/acquire-item.cc: - do not try PDiff if it is not listed in the Meta file --- apt-pkg/acquire-item.cc | 13 ++++++++----- apt-pkg/indexrecords.cc | 5 +++++ apt-pkg/indexrecords.h | 2 ++ 3 files changed, 15 insertions(+), 5 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index c035b9163..9e29f8189 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -1105,13 +1105,16 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify) /*{{{*/ return; } } - - // Queue Packages file (either diff or full packages files, depending - // on the users option) - if(_config->FindB("Acquire::PDiffs",true) == true) + + /* Queue Packages file (either diff or full packages files, depending + on the users option) - we also check if the PDiff Index file is listed + in the Meta-Index file. Ideal would be if pkgAcqDiffIndex would test this + instead, but passing the required info to it is to much hassle */ + if(_config->FindB("Acquire::PDiffs",true) == true && (verify == false || + MetaIndexParser->Exists(string((*Target)->MetaKey).append(".diff/Index")) == true)) new pkgAcqDiffIndex(Owner, (*Target)->URI, (*Target)->Description, (*Target)->ShortDesc, ExpectedIndexHash); - else + else new pkgAcqIndex(Owner, (*Target)->URI, (*Target)->Description, (*Target)->ShortDesc, ExpectedIndexHash); } diff --git a/apt-pkg/indexrecords.cc b/apt-pkg/indexrecords.cc index 1fc27b1a1..9a9600531 100644 --- a/apt-pkg/indexrecords.cc +++ b/apt-pkg/indexrecords.cc @@ -31,6 +31,11 @@ const indexRecords::checkSum *indexRecords::Lookup(const string MetaKey) return Entries[MetaKey]; } +bool indexRecords::Exists(string const &MetaKey) const +{ + return Entries.count(MetaKey) == 1; +} + bool indexRecords::Load(const string Filename) /*{{{*/ { FileFd Fd(Filename, FileFd::ReadOnly); diff --git a/apt-pkg/indexrecords.h b/apt-pkg/indexrecords.h index 468d2bd0f..2e3103b70 100644 --- a/apt-pkg/indexrecords.h +++ b/apt-pkg/indexrecords.h @@ -34,6 +34,8 @@ class indexRecords // Lookup function virtual const checkSum *Lookup(const string MetaKey); + /** \brief tests if a checksum for this file is available */ + bool Exists(string const &MetaKey) const; std::vector MetaKeys(); virtual bool Load(string Filename); -- cgit v1.2.3-70-g09d2