From e13ee75d4b20ee94e8da1b7f2be61788029b6875 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 27 Jan 2025 15:50:42 +0100 Subject: metaindex: Support loading without filename --- apt-pkg/metaindex.cc | 13 +++++++++++++ apt-pkg/metaindex.h | 1 + 2 files changed, 14 insertions(+) diff --git a/apt-pkg/metaindex.cc b/apt-pkg/metaindex.cc index f3df9b159..10c93de15 100644 --- a/apt-pkg/metaindex.cc +++ b/apt-pkg/metaindex.cc @@ -1,6 +1,7 @@ // Include Files /*{{{*/ #include +#include #include #include #include @@ -151,3 +152,15 @@ bool metaIndex::HasSupportForComponent(std::string const &) const/*{{{*/ return true; } /*}}}*/ +bool metaIndex::Load(std::string *ErrorText) /*{{{*/ +{ + auto debmeta = dynamic_cast(this); + if (not debmeta) + return false; + if (auto f = debmeta->MetaIndexFile("InRelease"); FileExists(f)) + return Load(f, ErrorText); + if (auto f = debmeta->MetaIndexFile("Release"); FileExists(f)) + return Load(f, ErrorText); + return false; +} + /*}}}*/ diff --git a/apt-pkg/metaindex.h b/apt-pkg/metaindex.h index e2a773c31..198c3f34a 100644 --- a/apt-pkg/metaindex.h +++ b/apt-pkg/metaindex.h @@ -96,6 +96,7 @@ public: virtual std::vector *GetIndexFiles() = 0; virtual bool IsTrusted() const = 0; virtual bool Load(std::string const &Filename, std::string * const ErrorText) = 0; + bool Load(std::string *const ErrorText); /** @return a new metaIndex object based on this one, but without information from #Load */ virtual metaIndex * UnloadedClone() const = 0; // the given metaIndex is potentially invalid after this call and should be deleted -- cgit v1.2.3-70-g09d2