diff --git a/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp b/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp
index 67314b91..e01396d7 100644
--- a/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp
+++ b/lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp
@@ -520,6 +520,7 @@ void XMLCALL ChapterHtmlSlimParser::startElement(void* userData, const XML_Char*
// Create page for image - only break if image won't fit remaining space
if (self->currentPage && !self->currentPage->elements.empty() &&
(self->currentPageNextY + displayHeight > self->viewportHeight)) {
+ self->paragraphIndexPerPage.push_back(self->xpathParagraphIndex);
self->completePageFn(std::move(self->currentPage));
self->completedPageCount++;
self->currentPage.reset(new Page());
diff --git a/lib/KOReaderSync/ChapterXPathForwardMapper.cpp b/lib/KOReaderSync/ChapterXPathForwardMapper.cpp
index 59477a0b..d6120166 100644
--- a/lib/KOReaderSync/ChapterXPathForwardMapper.cpp
+++ b/lib/KOReaderSync/ChapterXPathForwardMapper.cpp
@@ -99,6 +99,13 @@ std::string makeSpineCacheKey(const std::shared_ptr& epub, const int spine
size_t getTotalTextBytesCached(const std::shared_ptr& epub, const int spineIndex, const std::string& tmpPath) {
static std::unordered_map sTotalBytesBySpine;
+ static std::string sCachedBookPath;
+
+ const std::string currentBookPath = epub ? epub->getCachePath() : std::string();
+ if (currentBookPath != sCachedBookPath) {
+ sTotalBytesBySpine.clear();
+ sCachedBookPath = currentBookPath;
+ }
const std::string key = makeSpineCacheKey(epub, spineIndex);
if (!key.empty()) {
diff --git a/lib/KOReaderSync/ChapterXPathIndexerInternal.cpp b/lib/KOReaderSync/ChapterXPathIndexerInternal.cpp
index a81fd71e..920d30b7 100644
--- a/lib/KOReaderSync/ChapterXPathIndexerInternal.cpp
+++ b/lib/KOReaderSync/ChapterXPathIndexerInternal.cpp
@@ -3,6 +3,7 @@
#include
#include
+#include
#include
#include
#include
@@ -10,9 +11,8 @@
namespace ChapterXPathIndexerInternal {
std::string toLowerStr(std::string value) {
- for (char& c : value) {
- c = static_cast(std::tolower(static_cast(c)));
- }
+ std::transform(value.begin(), value.end(), value.begin(),
+ [](unsigned char c) { return static_cast(std::tolower(c)); });
return value;
}
@@ -186,7 +186,7 @@ std::string decompressToTempFile(const std::shared_ptr& epub, const int sp
return "";
}
- const std::string tmpPath = epub->getCachePath() + "/.tmp_kox.html";
+ const std::string tmpPath = epub->getCachePath() + "/.tmp_kox_" + std::to_string(spineIndex) + ".html";
if (Storage.exists(tmpPath.c_str())) {
Storage.remove(tmpPath.c_str());
}
diff --git a/lib/KOReaderSync/ChapterXPathIndexerState.h b/lib/KOReaderSync/ChapterXPathIndexerState.h
index f0c3b419..fddbea12 100644
--- a/lib/KOReaderSync/ChapterXPathIndexerState.h
+++ b/lib/KOReaderSync/ChapterXPathIndexerState.h
@@ -15,6 +15,7 @@ namespace ChapterXPathIndexerInternal {
struct StackNode {
std::string tag;
int index = 1;
+ // Reserved for future text-node heuristics; intentionally unused for now.
bool hasText = false;
};