From f96601e1ba1d5de81e220c7f35945ff9eedfe099 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Sun, 24 May 2026 20:40:41 +0200 Subject: [PATCH] Revert "Fix pagelist retrieval oom" This reverts commit 2f9d0520601537d386752fe46aba24d92180e7a6. --- lib/Epub/Epub/parsers/PageListSink.cpp | 50 ------------------------ lib/Epub/Epub/parsers/PageListSink.h | 52 ------------------------- lib/Epub/Epub/parsers/PageMapParser.cpp | 6 +-- lib/Epub/Epub/parsers/PageMapParser.h | 20 ++++++---- lib/Epub/Epub/parsers/TocNavParser.cpp | 9 ++--- lib/Epub/Epub/parsers/TocNavParser.h | 23 +++++++---- lib/Epub/Epub/parsers/TocNcxParser.cpp | 5 +-- lib/Epub/Epub/parsers/TocNcxParser.h | 21 ++++++---- 8 files changed, 51 insertions(+), 135 deletions(-) delete mode 100644 lib/Epub/Epub/parsers/PageListSink.cpp delete mode 100644 lib/Epub/Epub/parsers/PageListSink.h diff --git a/lib/Epub/Epub/parsers/PageListSink.cpp b/lib/Epub/Epub/parsers/PageListSink.cpp deleted file mode 100644 index 263ccc8f..00000000 --- a/lib/Epub/Epub/parsers/PageListSink.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "PageListSink.h" - -#include -#include - -PageListSink::PageListSink(const std::string& cachePath) : path(cachePath + "/pagelist.bin") { - if (!Storage.openFileForWrite("EBP", path, file)) { - LOG_ERR("EBP", "PageListSink: could not open pagelist.bin for writing"); - return; - } - // Placeholder count; patched in finalize(). - serialization::writePod(file, static_cast(0)); -} - -PageListSink::~PageListSink() { - if (!finalized) { - finalize(); - } -} - -void PageListSink::addEntry(const std::string& href, const std::string& anchor, const std::string& label) { - if (!file.isOpen() || finalized) return; - serialization::writeString(file, href); - serialization::writeString(file, anchor); - serialization::writeString(file, label); - count++; -} - -void PageListSink::finalize() { - if (finalized) return; - finalized = true; - if (!file.isOpen()) return; - - if (count == 0) { - file.close(); - Storage.remove(path.c_str()); - return; - } - - file.flush(); - if (!file.seek(0)) { - LOG_ERR("EBP", "PageListSink: could not seek to patch count"); - file.close(); - return; - } - serialization::writePod(file, count); - file.flush(); - file.close(); - LOG_DBG("EBP", "Wrote pagelist.bin with %u entries", static_cast(count)); -} diff --git a/lib/Epub/Epub/parsers/PageListSink.h b/lib/Epub/Epub/parsers/PageListSink.h deleted file mode 100644 index dea52ac3..00000000 --- a/lib/Epub/Epub/parsers/PageListSink.h +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once - -#include - -#include - -// Streams printed-page entries (href, anchor, label) directly to pagelist.bin -// instead of buffering them in a std::vector. Buffering blows the X3 heap on -// books with long EPUB 3