ALT Linux Bugzilla
– Attachment 10230 Details for
Bug 41816
libapt кэширует информацию о подключенных репозиториях без API для её удаления или обновления
New bug
|
Search
|
[?]
|
Help
Register
|
Log In
[x]
|
Forgot Password
Login:
[x]
|
EN
|
RU
[patch]
invalidate the in-memory cache
0001-add-use-pkgIndexFile-InvalidateReleases-to-update-in.patch (text/plain), 8.05 KB, created by
Ivan Zakharyaschev
on 2022-01-31 14:38:26 MSK
(
hide
)
Description:
invalidate the in-memory cache
Filename:
MIME Type:
Creator:
Ivan Zakharyaschev
Created:
2022-01-31 14:38:26 MSK
Size:
8.05 KB
patch
obsolete
>From 59d1cbb072d75f97ca993506e0f2b27d4a594da5 Mon Sep 17 00:00:00 2001 >From: Ivan Zakharyaschev <imz@altlinux.org> >Date: Mon, 31 Jan 2022 12:56:33 +0300 >Subject: [PATCH] add & use pkgIndexFile::InvalidateReleases() to update > in-memory cache (ALT#41816) > >Probably, the global variable RepList (in rpmindexfile.cc) is needed >to join/de-duplicate the information about the same pkgRepository >objects. pkgRepository::Acquire is set to false once they have been >downloaded (probably, to avoid downloading twice--by means of this >boolean flag). But there was no way to force a re-download. > >One solution is to set it back to true. >Another solution could be to delete the found pkgRepository object, >(as in the patch suggested in https://bugzilla.altlinux.org/41816 ) >and let the cacheFile object and ListUpdate() function re-build it >and re-download the stuff. > >This issue should probably be also relevant for apt-shell >(i.e., several invocations of "update" commands). TODO: test this >issue inside the apt project. > >Unlike in the patch suggested by darktemplar@ >in https://bugzilla.altlinux.org/41816 , this solution >wouldn't require restructuring the "refresh" code in PackageKit, >because it's OK to first re-download the releases, and only then >to clear the on-disk cache and re-build it. >And that patch explicitly brought a more private rpm-specific header >into the generic apt-pkg code (which should have stayed generic). >Perhaps, there was some danger that after deleting the elements >of RepList, there would remain dangling pointers >in rpmListIndex::Repository. > >Reported-by: Aleksei Nikiforov <darktemplar@altlinux.org> >--- > apt-pkg/indexfile.h | 4 ++++ > apt-pkg/rpm/rpmindexfile.cc | 10 ++++++++++ > apt-pkg/rpm/rpmindexfile.h | 6 ++++++ > apt-pkg/sourcelist.cc | 12 ++++++++++++ > apt-pkg/sourcelist.h | 1 + > apt-pkg/update.cc | 2 +- > cmdline/apt-get.cc | 4 +++- > cmdline/apt-shell.cc | 2 +- > 8 files changed, 38 insertions(+), 3 deletions(-) > >diff --git a/apt-pkg/indexfile.h b/apt-pkg/indexfile.h >index 817233bd7..76a06ed01 100644 >--- a/apt-pkg/indexfile.h >+++ b/apt-pkg/indexfile.h >@@ -64,6 +64,10 @@ class pkgIndexFile > virtual bool GetIndexes(pkgAcquire *Owner) const; > > // CNC:2002-07-04 >+ // The API has been extended in ALT for updating the in-memory cache >+ // (namely, the contents of the pkgRepository objects stored in RepList >+ // in rpmindexfile.cc; see https://bugzilla.altlinux.org/41816 ). >+ virtual bool InvalidateReleases() const = 0; // the extension made in ALT > virtual bool GetReleases(pkgAcquire *Owner) const = 0; > > // Interface for the record parsers >diff --git a/apt-pkg/rpm/rpmindexfile.cc b/apt-pkg/rpm/rpmindexfile.cc >index 62a446284..3fd0db1b3 100644 >--- a/apt-pkg/rpm/rpmindexfile.cc >+++ b/apt-pkg/rpm/rpmindexfile.cc >@@ -89,6 +89,16 @@ string rpmListIndex::ReleaseInfo(const string Type) const > return Info; > } > /*}}}*/ >+// rpmListIndex::InvalidateReleases - Mark the index files for refetching /*{{{*/ >+// --------------------------------------------------------------------- >+/* */ >+bool rpmListIndex::InvalidateReleases() const >+{ >+ if (Repository) // FIXME: GetReleases() did no such check. Who's right? >+ Repository->Acquire = true; >+ return true; >+} >+ /*}}}*/ > // rpmListIndex::GetReleases - Fetch the index files /*{{{*/ > // --------------------------------------------------------------------- > /* */ >diff --git a/apt-pkg/rpm/rpmindexfile.h b/apt-pkg/rpm/rpmindexfile.h >index b7148b38c..14baa13b1 100644 >--- a/apt-pkg/rpm/rpmindexfile.h >+++ b/apt-pkg/rpm/rpmindexfile.h >@@ -45,6 +45,7 @@ class rpmDatabaseIndex : public rpmIndexFile > virtual string Describe(bool Short) const override {return "RPM Database";} > > /* nothing to download in the case of the DB */ >+ virtual bool InvalidateReleases() const override { return true; } > virtual bool GetReleases(pkgAcquire *Owner) const override { return true; } > > // Interface for the Cache Generator >@@ -83,6 +84,7 @@ class rpmListIndex : public rpmIndexFile > > public: > >+ virtual bool InvalidateReleases() const override; > virtual bool GetReleases(pkgAcquire *Owner) const override; > > // Interface for the Cache Generator >@@ -183,6 +185,7 @@ class rpmPkgDirIndex : public rpmPkgListIndex > > public: > >+ virtual bool InvalidateReleases() const override { return true; } > virtual bool GetReleases(pkgAcquire *Owner) const override { return true; } > virtual bool GetIndexes(pkgAcquire *Owner) const override { return true; } > >@@ -210,6 +213,7 @@ class rpmSrcDirIndex : public rpmSrcListIndex > > public: > >+ virtual bool InvalidateReleases() const override { return true; } > virtual bool GetReleases(pkgAcquire *Owner) const override { return true; } > virtual bool GetIndexes(pkgAcquire *Owner) const override { return true; } > >@@ -239,6 +243,7 @@ class rpmSinglePkgIndex : public rpmPkgListIndex > > public: > >+ virtual bool InvalidateReleases() const override { return true; } > virtual bool GetReleases(pkgAcquire *Owner) const override { return true; } > virtual bool GetIndexes(pkgAcquire *Owner) const override { return true; } > >@@ -265,6 +270,7 @@ class rpmSingleSrcIndex : public rpmSrcListIndex > > public: > >+ virtual bool InvalidateReleases() const override { return true; } > virtual bool GetReleases(pkgAcquire *Owner) const override { return true; } > virtual bool GetIndexes(pkgAcquire *Owner) const override { return true; } > >diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc >index 8e3f0ce74..6b15dab27 100644 >--- a/apt-pkg/sourcelist.cc >+++ b/apt-pkg/sourcelist.cc >@@ -419,6 +419,18 @@ bool pkgSourceList::GetIndexes(pkgAcquire *Owner) const > return true; > } > /*}}}*/ >+// CNC:2002-07-04's extension by ALT >+// SourceList::IvalidateReleases - Mark all releases to be re-fetched /*{{{*/ >+// --------------------------------------------------------------------- >+/* */ >+bool pkgSourceList::InvalidateReleases() const >+{ >+ for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++) >+ if ((*I)->InvalidateReleases() == false) >+ return false; >+ return true; >+} >+ /*}}}*/ > // CNC:2002-07-04 > // SourceList::GetReleases - Load release files into the downloader /*{{{*/ > // --------------------------------------------------------------------- >diff --git a/apt-pkg/sourcelist.h b/apt-pkg/sourcelist.h >index 9e08aba7b..27fb1850b 100644 >--- a/apt-pkg/sourcelist.h >+++ b/apt-pkg/sourcelist.h >@@ -106,6 +106,7 @@ class pkgSourceList > bool GetIndexes(pkgAcquire *Owner) const; > > // CNC:2002-07-04 >+ bool InvalidateReleases() const; // ALT's extension > bool GetReleases(pkgAcquire *Owner) const; > > pkgSourceList(); >diff --git a/apt-pkg/update.cc b/apt-pkg/update.cc >index 1a2b77ae5..12672cba6 100644 >--- a/apt-pkg/update.cc >+++ b/apt-pkg/update.cc >@@ -61,7 +61,7 @@ bool ListUpdate(pkgAcquireStatus &Stat, > bool Res = true; > > // Populate it with release file URIs >- if (!List.GetReleases(&Fetcher)) >+ if (! (List.InvalidateReleases() && List.GetReleases(&Fetcher)) ) > return false; > > res = Fetcher.Run(); >diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc >index 3c2420e0a..669cfe180 100644 >--- a/cmdline/apt-get.cc >+++ b/cmdline/apt-get.cc >@@ -1139,7 +1139,9 @@ bool DoUpdate(CommandLine &CmdL) > pkgAcquire Fetcher(&Stat); > > // Populate it with release file URIs >- if (!List.GetReleases(&Fetcher)) >+ // InvalidateReleases() isn't really necessary, since apt-get is >+ // a one-shot process. It's here for consistency (with other utilities). >+ if (! (List.InvalidateReleases() && List.GetReleases(&Fetcher)) ) > return false; > > // Populate it with the source selection >diff --git a/cmdline/apt-shell.cc b/cmdline/apt-shell.cc >index b1809b8bd..0f345f567 100644 >--- a/cmdline/apt-shell.cc >+++ b/cmdline/apt-shell.cc >@@ -1067,7 +1067,7 @@ bool DoUpdate(CommandLine &CmdL) > pkgAcquire Fetcher(&Stat); > > // Populate it with release file URIs >- if (!List.GetReleases(&Fetcher)) >+ if (! (List.InvalidateReleases() && List.GetReleases(&Fetcher)) ) > return false; > > // Populate it with the source selection >-- >2.25.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 41816
:
10219
| 10230