From 2d5bbf0e98de71910df24a046197d7803ace6ebe Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 11 Mar 2020 19:50:08 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/model/localBook/AnalyzeTxtFile.kt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt b/app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt index 16426a036..9199ae05a 100644 --- a/app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt +++ b/app/src/main/java/io/legado/app/model/localBook/AnalyzeTxtFile.kt @@ -193,15 +193,18 @@ object AnalyzeTxtFile { } private fun getBookFile(context: Context, book: Book): File { - val uri = Uri.parse(book.bookUrl) - val bookFile = FileUtils.getFile(cacheFolder, book.originName, subDirs = *arrayOf()) - if (!bookFile.exists()) { - bookFile.createNewFile() - DocumentUtils.readBytes(context, uri)?.let { - bookFile.writeBytes(it) + if (book.bookUrl.isContentPath()) { + val uri = Uri.parse(book.bookUrl) + val bookFile = FileUtils.getFile(cacheFolder, book.originName, subDirs = *arrayOf()) + if (!bookFile.exists()) { + bookFile.createNewFile() + DocumentUtils.readBytes(context, uri)?.let { + bookFile.writeBytes(it) + } } + return bookFile } - return bookFile + return File(book.bookUrl) } private fun getTocRule(book: Book, bookStream: RandomAccessFile, charset: Charset): Pattern? {