diff options
author | Julian Andres Klode <julian.klode@canonical.com> | 2024-03-21 22:18:08 +0100 |
---|---|---|
committer | Julian Andres Klode <julian.klode@canonical.com> | 2024-03-22 11:10:24 +0100 |
commit | 5414789489f9814aaacdc6169975bae1b871a44f (patch) | |
tree | b8b418251440c473f6f74d95946ab72cd9fb36bb /apt-pkg/deb | |
parent | 2534288b97c5e0dfd0bf900c32166b5595e5bbe7 (diff) |
debrecords: Do not reparse if given same location
The TagFile parser will have already parsed further and can't go
back so it needs to reopen the file if compressed.
Closes: #1067440
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r-- | apt-pkg/deb/debrecords.cc | 14 | ||||
-rw-r--r-- | apt-pkg/deb/debrecords.h | 3 |
2 files changed, 14 insertions, 3 deletions
diff --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc index b9d1b6e2f..438b147bd 100644 --- a/apt-pkg/deb/debrecords.cc +++ b/apt-pkg/deb/debrecords.cc @@ -31,9 +31,13 @@ using std::string; +struct debRecordParser::Private { + unsigned long long Offset = -1; +}; + // RecordParser::debRecordParser - Constructor /*{{{*/ debRecordParser::debRecordParser(string FileName,pkgCache &Cache) : - debRecordParserBase(), d(NULL), File(FileName, FileFd::ReadOnly, FileFd::Extension), + debRecordParserBase(), d(new Private), File(FileName, FileFd::ReadOnly, FileFd::Extension), Tags(&File, std::max(Cache.Head().MaxVerFileSize, Cache.Head().MaxDescFileSize) + 200) { } @@ -41,18 +45,24 @@ debRecordParser::debRecordParser(string FileName,pkgCache &Cache) : // RecordParser::Jump - Jump to a specific record /*{{{*/ bool debRecordParser::Jump(pkgCache::VerFileIterator const &Ver) { + if (d->Offset == Ver->Offset) + return true; if (Ver.end() == true) return false; + d->Offset = Ver->Offset; return Tags.Jump(Section,Ver->Offset); } bool debRecordParser::Jump(pkgCache::DescFileIterator const &Desc) { + if (d->Offset == Desc->Offset) + return true; if (Desc.end() == true) return false; + d->Offset = Desc->Offset; return Tags.Jump(Section,Desc->Offset); } /*}}}*/ -debRecordParser::~debRecordParser() {} +debRecordParser::~debRecordParser() { delete d; } debRecordParserBase::debRecordParserBase() : Parser(), d(NULL) {} // RecordParserBase::FileName - Return the archive filename on the site /*{{{*/ diff --git a/apt-pkg/deb/debrecords.h b/apt-pkg/deb/debrecords.h index 10ef91768..d81bdf08f 100644 --- a/apt-pkg/deb/debrecords.h +++ b/apt-pkg/deb/debrecords.h @@ -53,7 +53,8 @@ class APT_HIDDEN debRecordParserBase : public pkgRecords::Parser class APT_HIDDEN debRecordParser : public debRecordParserBase { - void * const d; + struct Private; + Private *d; protected: FileFd File; pkgTagFile Tags; |