From 1f14a6a885649e96c6f02b14435de85e17d7ca5b Mon Sep 17 00:00:00 2001 From: Aleksei Nikiforov Date: Thu, 27 Jan 2022 14:35:59 +0300 Subject: [PATCH] Removing caches also removes in-memory repository metainfo cache --- apt-pkg/cachefile.cc | 4 ++++ apt-pkg/repository.h | 1 + apt-pkg/rpm/rpmindexfile.cc | 10 ++++++++++ apt-pkg/rpm/rpmindexfile.h | 2 ++ 4 files changed, 17 insertions(+) diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc index f81c26a4..1a54a933 100644 --- a/apt-pkg/cachefile.cc +++ b/apt-pkg/cachefile.cc @@ -32,6 +32,8 @@ #include #include + +#include "rpm/rpmindexfile.h" /*}}}*/ // lazyCacheFile::lazyCacheFile - Constructor /*{{{*/ @@ -241,6 +243,8 @@ void pkgCacheFile::RemoveCaches() const std::string pkgcache = _config->FindFile("Dir::Cache::pkgcache"); const std::string srcpkgcache = _config->FindFile("Dir::Cache::srcpkgcache"); + removeRepositoryCaches(); + if ((!pkgcache.empty()) && RealFileExists(pkgcache)) RemoveFile("RemoveCaches", pkgcache); if ((!srcpkgcache.empty()) && RealFileExists(srcpkgcache)) diff --git a/apt-pkg/repository.h b/apt-pkg/repository.h index b0ff0913..e6a1838d 100644 --- a/apt-pkg/repository.h +++ b/apt-pkg/repository.h @@ -52,6 +52,7 @@ class pkgRepository if (Vendor) FingerPrintList = Vendor->FingerPrintList; } + virtual ~pkgRepository() = default; }; #endif diff --git a/apt-pkg/rpm/rpmindexfile.cc b/apt-pkg/rpm/rpmindexfile.cc index 1fc454df..f55cb123 100644 --- a/apt-pkg/rpm/rpmindexfile.cc +++ b/apt-pkg/rpm/rpmindexfile.cc @@ -34,6 +34,16 @@ /*}}}*/ vector RepList; +void removeRepositoryCaches() +{ + for (auto iter = RepList.begin(); iter != RepList.end(); ++iter) + { + delete *iter; + } + + RepList.clear(); +} + // rpmListIndex::Release* - Return the URI to the release file /*{{{*/ // --------------------------------------------------------------------- /* */ diff --git a/apt-pkg/rpm/rpmindexfile.h b/apt-pkg/rpm/rpmindexfile.h index 5f24e25c..13ee7c25 100644 --- a/apt-pkg/rpm/rpmindexfile.h +++ b/apt-pkg/rpm/rpmindexfile.h @@ -23,6 +23,8 @@ class RPMHandler; class RPMDBHandler; class pkgRepository; +void removeRepositoryCaches(); + class rpmIndexFile : public pkgIndexFile { -- 2.33.0