Fix section hash

This commit is contained in:
jpirnay
2026-05-10 21:26:52 +02:00
parent ba30ed029f
commit f48636c2b9
+7 -4
View File
@@ -353,6 +353,9 @@ bool Section::createSectionFile(const int fontId, const float lineCompression, c
return false; return false;
} }
// Evict old variants for this spine to keep cache size controlled BEFORE creating the new one
evictOldVariants();
if (!Storage.openFileForWrite("SCT", filePath, file)) { if (!Storage.openFileForWrite("SCT", filePath, file)) {
return false; return false;
} }
@@ -365,9 +368,6 @@ bool Section::createSectionFile(const int fontId, const float lineCompression, c
std::string contentBase = (lastSlash != std::string::npos) ? localPath.substr(0, lastSlash + 1) : ""; std::string contentBase = (lastSlash != std::string::npos) ? localPath.substr(0, lastSlash + 1) : "";
std::string imageBasePath = getImageBasePath(propertyHash); std::string imageBasePath = getImageBasePath(propertyHash);
// Evict old variants for this spine to keep cache size controlled
evictOldVariants();
CssParser* cssParser = nullptr; CssParser* cssParser = nullptr;
if (embeddedStyle) { if (embeddedStyle) {
cssParser = epub->getCssParser(); cssParser = epub->getCssParser();
@@ -483,13 +483,16 @@ bool Section::createSectionFile(const int fontId, const float lineCompression, c
serialization::writePod(file, lutOffset); serialization::writePod(file, lutOffset);
serialization::writePod(file, anchorMapOffset); serialization::writePod(file, anchorMapOffset);
serialization::writePod(file, paragraphLutOffset); serialization::writePod(file, paragraphLutOffset);
file.close(); file.flush();
if (cssParser) { if (cssParser) {
cssParser->clear(); cssParser->clear();
} }
buildTocBoundaries(anchors); buildTocBoundaries(anchors);
file.close();
// Cache the LUT in memory and open the file for reading so that // Cache the LUT in memory and open the file for reading so that
// subsequent loadPageFromSectionFile() calls can seek directly without re-opening. // subsequent loadPageFromSectionFile() calls can seek directly without re-opening.
if (!Storage.openFileForRead("SCT", filePath, file)) { if (!Storage.openFileForRead("SCT", filePath, file)) {