diff options
author | David Kalnischkies <david@kalnischkies.de> | 2015-06-23 15:16:08 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2015-08-10 17:25:26 +0200 |
commit | 5ad0096a4e19e191b59634e8a8817995ec4045ad (patch) | |
tree | 70b2310cdff52e809ffebcdfae4ffa4cd42f10fb /apt-pkg/metaindex.cc | |
parent | 268ffcebb9ae4278b1e3c3f89f8167f229164dbd (diff) |
merge indexRecords into metaIndex
indexRecords was used to parse the Release file – mostly the hashes –
while metaIndex deals with downloading the Release file, storing all
indexes coming from this release and … parsing the Release file, but
this time mostly for the other fields.
That wasn't a problem in metaIndex as this was done in the type specific
subclass, but indexRecords while allowing to override the parsing method
did expect by default a specific format.
APT isn't really supporting different types at the moment, but this is
a violation of the abstraction we have everywhere else and, which is the
actual reason for this merge: Options e.g. coming from the sources.list
come to metaIndex naturally, which needs to wrap them up and bring them
into indexRecords, so the acquire system is told about it as they don't
get to see the metaIndex, but they don't really belong in indexRecords
as this is just for storing data loaded from the Release file… the
result is a complete mess.
I am not saying it is a lot prettier after the merge, but at least
adding new options is now slightly easier and there is just one place
responsible for parsing the Release file. That can't hurt.
Diffstat (limited to 'apt-pkg/metaindex.cc')
-rw-r--r-- | apt-pkg/metaindex.cc | 76 |
1 files changed, 60 insertions, 16 deletions
diff --git a/apt-pkg/metaindex.cc b/apt-pkg/metaindex.cc index 0c88ee9cd..8bd13bb18 100644 --- a/apt-pkg/metaindex.cc +++ b/apt-pkg/metaindex.cc @@ -9,20 +9,6 @@ #include <vector> /*}}}*/ -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) -std::string metaIndex::LocalFileName() const { return ""; } -#else -#include <apt-pkg/debmetaindex.h> -std::string metaIndex::LocalFileName() const -{ - debReleaseIndex const * deb = dynamic_cast<debReleaseIndex const*>(this); - if (deb != NULL) - return deb->LocalFileName(); - - return ""; -} -#endif - std::string metaIndex::Describe() const { return "Release"; @@ -38,10 +24,11 @@ bool metaIndex::Merge(pkgCacheGenerator &Gen,OpProgress *) const return Gen.SelectReleaseFile("", ""); } - metaIndex::metaIndex(std::string const &URI, std::string const &Dist, char const * const Type) -: d(NULL), Indexes(NULL), Type(Type), URI(URI), Dist(Dist) +: d(NULL), Indexes(NULL), Type(Type), URI(URI), Dist(Dist), Trusted(TRI_UNSET), + LoadedSuccessfully(TRI_UNSET), + Date(0), ValidUntil(0), SupportsAcquireByHash(false) { /* nothing */ } @@ -55,3 +42,60 @@ metaIndex::~metaIndex() delete *I; delete Indexes; } + +// one line Getters for public fields /*{{{*/ +APT_PURE std::string metaIndex::GetURI() const { return URI; } +APT_PURE std::string metaIndex::GetDist() const { return Dist; } +APT_PURE const char* metaIndex::GetType() const { return Type; } +APT_PURE metaIndex::TriState metaIndex::GetTrusted() const { return Trusted; } +APT_PURE std::string metaIndex::GetCodename() const { return Codename; } +APT_PURE std::string metaIndex::GetSuite() const { return Suite; } +APT_PURE bool metaIndex::GetSupportsAcquireByHash() const { return SupportsAcquireByHash; } +APT_PURE time_t metaIndex::GetValidUntil() const { return ValidUntil; } +APT_PURE time_t metaIndex::GetDate() const { return this->Date; } +APT_PURE metaIndex::TriState metaIndex::GetLoadedSuccessfully() const { return LoadedSuccessfully; } + +APT_PURE bool metaIndex::CheckDist(string const &MaybeDist) const +{ + return (this->Codename == MaybeDist + || this->Suite == MaybeDist); +} +APT_PURE std::string metaIndex::GetExpectedDist() const +{ + // TODO: Used to be an explicit value set in the constructor + return ""; +} + /*}}}*/ +APT_PURE metaIndex::checkSum *metaIndex::Lookup(string const &MetaKey) const /*{{{*/ +{ + std::map<std::string, metaIndex::checkSum* >::const_iterator sum = Entries.find(MetaKey); + if (sum == Entries.end()) + return NULL; + return sum->second; +} + /*}}}*/ +APT_PURE bool metaIndex::Exists(string const &MetaKey) const /*{{{*/ +{ + return Entries.find(MetaKey) != Entries.end(); +} + /*}}}*/ +std::vector<std::string> metaIndex::MetaKeys() const /*{{{*/ +{ + std::vector<std::string> keys; + std::map<string,checkSum *>::const_iterator I = Entries.begin(); + while(I != Entries.end()) { + keys.push_back((*I).first); + ++I; + } + return keys; +} + /*}}}*/ +void metaIndex::swapLoad(metaIndex * const OldMetaIndex) /*{{{*/ +{ + std::swap(Entries, OldMetaIndex->Entries); + std::swap(Date, OldMetaIndex->Date); + std::swap(ValidUntil, OldMetaIndex->ValidUntil); + std::swap(SupportsAcquireByHash, OldMetaIndex->SupportsAcquireByHash); + std::swap(LoadedSuccessfully, OldMetaIndex->LoadedSuccessfully); +} + /*}}}*/ |