From 15cb3feee4be0a129bd11a9204d9d35f6b5a9aa0 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 29 Jan 2020 08:33:24 +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/src/main/java/io/legado/app/help/BookHelp.kt | 2 +- app/src/main/java/io/legado/app/utils/DocumentUtils.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/BookHelp.kt b/app/src/main/java/io/legado/app/help/BookHelp.kt index 6c65af7ed..f800800ff 100644 --- a/app/src/main/java/io/legado/app/help/BookHelp.kt +++ b/app/src/main/java/io/legado/app/help/BookHelp.kt @@ -83,7 +83,7 @@ object BookHelp { fun getChapterCount(book: Book): Int { if (downloadUri.isDocumentUri(App.INSTANCE)) { DocumentFile.fromTreeUri(App.INSTANCE, downloadUri)?.let { - return DocumentUtils.createFileIfNotExist( + return DocumentUtils.createFolderIfNotExist( it, subDirs = *arrayOf(cacheFolderName, bookFolderName(book)) )?.listFiles()?.size ?: 0 diff --git a/app/src/main/java/io/legado/app/utils/DocumentUtils.kt b/app/src/main/java/io/legado/app/utils/DocumentUtils.kt index 3d1f53a58..8e74c63e0 100644 --- a/app/src/main/java/io/legado/app/utils/DocumentUtils.kt +++ b/app/src/main/java/io/legado/app/utils/DocumentUtils.kt @@ -17,11 +17,11 @@ object DocumentUtils { mimeType: String = "", vararg subDirs: String ): DocumentFile? { - val parent: DocumentFile? = createFileIfNotExist(root, *subDirs) + val parent: DocumentFile? = createFolderIfNotExist(root, *subDirs) return parent?.createFile(mimeType, fileName) } - fun createFileIfNotExist(root: DocumentFile, vararg subDirs: String): DocumentFile? { + fun createFolderIfNotExist(root: DocumentFile, vararg subDirs: String): DocumentFile? { var parent: DocumentFile? = root for (subDirName in subDirs) { val subDir = parent?.findFile(subDirName)