From 3357db03f4ada14ad3ada4f9e715bd62819031c8 Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Tue, 8 Feb 2022 09:22:03 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B9=A6=E7=B1=8D?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E6=9F=90=E4=BA=9B=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E7=9A=84=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/ui/book/info/BookInfoActivity.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt index fb0830572..981dbdebf 100644 --- a/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt @@ -127,8 +127,10 @@ class BookInfoActivity : viewModel.bookSource != null menu.findItem(R.id.menu_set_book_variable)?.isVisible = viewModel.bookSource != null + menu.findItem(R.id.menu_can_update)?.isVisible = + viewModel.bookSource != null menu.findItem(R.id.menu_limit_content_length)?.isVisible = - viewModel.bookSource == null + viewModel.bookData.value?.isLocalTxt() ?: false return super.onMenuOpened(featureId, menu) } From 8628f35ff5ca1d2ab14ad26adf79641056575772 Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Tue, 8 Feb 2022 09:53:51 +0800 Subject: [PATCH 2/3] localBook.kt:remove ununsed codes --- .../io/legado/app/model/localBook/LocalBook.kt | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt b/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt index 5b1027594..bcfc80324 100644 --- a/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt +++ b/app/src/main/java/io/legado/app/model/localBook/LocalBook.kt @@ -24,11 +24,6 @@ import javax.script.SimpleBindings object LocalBook { - private const val folderName = "bookTxt" - val cacheFolder: File by lazy { - FileUtils.createFolderIfNotExist(appCtx.externalFiles, folderName) - } - @Throws(FileNotFoundException::class, SecurityException::class) fun getBookInputStream(book: Book): InputStream { val uri = Uri.parse(book.bookUrl) @@ -168,15 +163,6 @@ object LocalBook { fun deleteBook(book: Book, deleteOriginal: Boolean) { kotlin.runCatching { - if (book.isLocalTxt() || book.isUmd()) { - cacheFolder.getFile(book.originName).delete() - } - if (book.isEpub()) { - FileUtils.delete( - cacheFolder.getFile(book.getFolderName()) - ) - } - if (deleteOriginal) { if (book.bookUrl.isContentScheme()) { val uri = Uri.parse(book.bookUrl) From b219ae533fb578293b617c8522f75cf97e42eb1f Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Tue, 8 Feb 2022 10:08:38 +0800 Subject: [PATCH 3/3] =?UTF-8?q?web=E4=BC=A0=E4=B9=A6=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E5=88=B0=E7=94=A8=E6=88=B7=E4=BD=8D=E7=BD=AE=E7=9A=84=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/api/controller/BookController.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/api/controller/BookController.kt b/app/src/main/java/io/legado/app/api/controller/BookController.kt index e0ba95bb5..c2b480aae 100644 --- a/app/src/main/java/io/legado/app/api/controller/BookController.kt +++ b/app/src/main/java/io/legado/app/api/controller/BookController.kt @@ -7,6 +7,7 @@ import io.legado.app.api.ReturnData import io.legado.app.constant.PreferKey import io.legado.app.data.appDb import io.legado.app.data.entities.Book +import io.legado.app.help.AppConfig import io.legado.app.help.BookHelp import io.legado.app.help.CacheManager import io.legado.app.help.ContentProcessor @@ -206,7 +207,9 @@ object BookController { ?: return returnData.setErrorMsg("fileName 不能为空") val fileData = parameters["fileData"]?.firstOrNull() ?: return returnData.setErrorMsg("fileData 不能为空") - val file = FileUtils.createFileIfNotExist(LocalBook.cacheFolder, fileName) + if (AppConfig.defaultBookTreeUri == null) return returnData.setErrorMsg("没有设置书籍保存位置!") + val bookFolder = FileUtils.createFolderIfNotExist(AppConfig.defaultBookTreeUri!!) + val file = FileUtils.createFileIfNotExist(bookFolder, fileName) val fileBytes = Base64.decode(fileData.substringAfter("base64,"), Base64.DEFAULT) file.writeBytes(fileBytes) val nameAuthor = LocalBook.analyzeNameAuthor(fileName)