From 029ef5eda34800957eaec7306679a0e85ce6b979 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 2 Feb 2022 21:44:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/association/FileAssociationActivity.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt b/app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt index 389ce22d5..133cce8a3 100644 --- a/app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt +++ b/app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt @@ -18,6 +18,7 @@ import io.legado.app.utils.viewbindingdelegate.viewBinding import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.launch import kotlinx.coroutines.withContext +import timber.log.Timber import java.io.File import java.io.FileOutputStream @@ -108,7 +109,8 @@ class FileAssociationActivity : var doc = treeDoc!!.findFile(name) if (doc == null || bookDoc.lastModified() > doc.lastModified()) { if (doc == null) { - doc = treeDoc.createFile(FileUtils.getMimeType(name), name)!! + doc = treeDoc.createFile(FileUtils.getMimeType(name), name) + ?: throw SecurityException("Permission Denial") } contentResolver.openOutputStream(doc.uri)!!.use { oStream -> contentResolver.openInputStream(bookDoc.uri)!!.use { iStream -> @@ -142,7 +144,11 @@ class FileAssociationActivity : title = "选择保存书籍的文件夹" mode = HandleFileContract.DIR_SYS } - else -> toastOnUi(it.localizedMessage) + else -> { + Timber.e(it, "导入书籍失败") + toastOnUi(it.localizedMessage) + finish() + } } } }