页表全量接管改为按子集覆盖判定

fullReplace 从"候选章节数 >= 当前章节数"改为"候选页表必须覆盖当前窗口
的全部章节",避免跳章后 partial map 数量达标但缺少远端已映射章节时,
全量替换丢弃这些条目导致总页数抖动。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
shenlei 2026-07-06 11:14:48 +09:00
parent 9e91207011
commit 47fe2dc450

View File

@ -164,6 +164,7 @@ final class RDEPUBPageMapReconciliationCoordinator {
lastBuildableSpineIndex: Int lastBuildableSpineIndex: Int
) -> RDEPUBPageMapTakeoverDecision { ) -> RDEPUBPageMapTakeoverDecision {
let candidateIndices = Set(candidatePageMap.entries.map { $0.spineIndex }) let candidateIndices = Set(candidatePageMap.entries.map { $0.spineIndex })
let currentIndices = Set(currentWindow.entries.map { $0.spineIndex })
let currentEntries = currentWindow.entries.count let currentEntries = currentWindow.entries.count
if let currentSpineIndex { if let currentSpineIndex {
@ -189,8 +190,8 @@ final class RDEPUBPageMapReconciliationCoordinator {
} }
} }
let isComplete = candidateIndices.count >= currentEntries let coversCurrentWindow = currentIndices.isSubset(of: candidateIndices)
if isComplete { if coversCurrentWindow {
RDEPUBBackgroundTrace.log( RDEPUBBackgroundTrace.log(
"Reconciliation", "Reconciliation",
"evaluateFullPageMapTakeover: fullReplace — candidateChapters=\(candidateIndices.count) currentChapters=\(currentEntries) candidatePages=\(candidatePageMap.totalPages) currentPages=\(currentWindow.totalPages)" "evaluateFullPageMapTakeover: fullReplace — candidateChapters=\(candidateIndices.count) currentChapters=\(currentEntries) candidatePages=\(candidatePageMap.totalPages) currentPages=\(currentWindow.totalPages)"
@ -198,6 +199,10 @@ final class RDEPUBPageMapReconciliationCoordinator {
return .fullReplace(candidatePageMap) return .fullReplace(candidatePageMap)
} }
RDEPUBBackgroundTrace.log(
"Reconciliation",
"evaluateFullPageMapTakeover: keepCurrentWindow — candidate does not cover currentWindow candidateChapters=\(candidateIndices.count) currentChapters=\(currentEntries)"
)
return .keepCurrentWindow return .keepCurrentWindow
} }