From 5404c768862dfb1fc2ecb3672a9aedb0c16f6933 Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Mon, 7 Feb 2022 11:55:51 +0800 Subject: [PATCH] =?UTF-8?q?txt=E8=A7=84=E5=88=99=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E5=AD=97=E6=95=B0=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/model/localBook/TextFile.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/model/localBook/TextFile.kt b/app/src/main/java/io/legado/app/model/localBook/TextFile.kt index 02c05ca29..e39c4f007 100644 --- a/app/src/main/java/io/legado/app/model/localBook/TextFile.kt +++ b/app/src/main/java/io/legado/app/model/localBook/TextFile.kt @@ -45,6 +45,8 @@ class TextFile(private val book: Book) { //没有标题的时候,每个章节的最大长度 private val maxLengthWithNoToc = 10 * 1024 + //使用正则划分目录,每个章节的最大允许长度 + private val maxLengthWithToc = 102400 private val tocRules = arrayListOf() private var charset: Charset = book.fileCharset() @@ -126,7 +128,7 @@ class TextFile(private val book: Book) { val chapterContent = blockContent.substring(seekPos, chapterStart) val chapterLength = chapterContent.toByteArray(charset).size val lastStart = toc.lastOrNull()?.start ?: curOffset - if (curOffset + chapterLength - lastStart > 102400) { + if (curOffset + chapterLength - lastStart > maxLengthWithToc) { bis.close() return analyze() }