From 64bf4e0f04b1d70a89914f0d7d42c27c25f51f3e Mon Sep 17 00:00:00 2001 From: gedoor Date: Mon, 31 Aug 2020 10:41:41 +0800 Subject: [PATCH] =?UTF-8?q?=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/src/main/java/io/legado/app/help/BookHelp.kt | 2 +- app/src/main/java/io/legado/app/help/CrashHandler.kt | 2 +- app/src/main/java/io/legado/app/help/storage/Backup.kt | 2 +- app/src/main/java/io/legado/app/utils/FileUtils.kt | 5 ----- 4 files changed, 3 insertions(+), 8 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 b6822303c..355b7454e 100644 --- a/app/src/main/java/io/legado/app/help/BookHelp.kt +++ b/app/src/main/java/io/legado/app/help/BookHelp.kt @@ -52,7 +52,7 @@ object BookHelp { App.db.bookDao().all.forEach { bookFolderNames.add(it.getFolderName()) } - val file = FileUtils.getDirFile(downloadDir, cacheFolderName) + val file = FileUtils.getFile(downloadDir, cacheFolderName) file.listFiles()?.forEach { bookFile -> if (!bookFolderNames.contains(bookFile.name)) { FileUtils.deleteFile(bookFile.absolutePath) diff --git a/app/src/main/java/io/legado/app/help/CrashHandler.kt b/app/src/main/java/io/legado/app/help/CrashHandler.kt index b59609e18..cee91e4a3 100644 --- a/app/src/main/java/io/legado/app/help/CrashHandler.kt +++ b/app/src/main/java/io/legado/app/help/CrashHandler.kt @@ -142,7 +142,7 @@ class CrashHandler : Thread.UncaughtExceptionHandler { val time = format.format(Date()) val fileName = "crash-$time-$timestamp.log" mContext?.externalCacheDir?.let { rootFile -> - FileUtils.getDirFile(rootFile, "crash").listFiles()?.forEach { + FileUtils.getFile(rootFile, "crash").listFiles()?.forEach { if (it.lastModified() < System.currentTimeMillis() - TimeUnit.DAYS.toMillis(7)) { it.delete() } diff --git a/app/src/main/java/io/legado/app/help/storage/Backup.kt b/app/src/main/java/io/legado/app/help/storage/Backup.kt index bec27b53a..81ea5cd08 100644 --- a/app/src/main/java/io/legado/app/help/storage/Backup.kt +++ b/app/src/main/java/io/legado/app/help/storage/Backup.kt @@ -18,7 +18,7 @@ import java.util.concurrent.TimeUnit object Backup { val backupPath: String by lazy { - FileUtils.getDirFile(App.INSTANCE.filesDir, "backup").absolutePath + FileUtils.getFile(App.INSTANCE.filesDir, "backup").absolutePath } val backupFileNames by lazy { diff --git a/app/src/main/java/io/legado/app/utils/FileUtils.kt b/app/src/main/java/io/legado/app/utils/FileUtils.kt index e84e6c9b7..a0b7b910f 100644 --- a/app/src/main/java/io/legado/app/utils/FileUtils.kt +++ b/app/src/main/java/io/legado/app/utils/FileUtils.kt @@ -54,11 +54,6 @@ object FileUtils { return File(filePath) } - fun getDirFile(root: File, vararg subDirs: String): File { - val filePath = getPath(root = root, *subDirs) - return File(filePath) - } - fun getPath(root: File, vararg subDirFiles: String): String { val path = StringBuilder(root.absolutePath) subDirFiles.forEach {