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] =?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)