Skip to content

Commit

Permalink
Fix #3001 (Empty fragment generated by Epub optimizer)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuomas2 committed Nov 4, 2023
1 parent 913022c commit 5e757de
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ fun EpubBackendState.optimizeEpub() {
val (origDocument, maxOrdinal) = readOriginal(k)
origDocument ?: continue

val fragments = splitIntoFragments(k, origDocument, maxOrdinal)
val fragments = splitIntoFragments(k, origDocument, maxOrdinal).let {
it.ifEmpty{ listOf(EpubFragment(k, 0, 0).apply { element = origDocument.rootElement }) }
}
val ids = writeDao.insert(*fragments.toTypedArray())
for((id, frag) in ids.zip(fragments)) {
frag.id = id
Expand Down

0 comments on commit 5e757de

Please sign in to comment.