From e25ce768bb546d850eb2134be967432a6fc7eb27 Mon Sep 17 00:00:00 2001 From: len Date: Thu, 26 Jan 2017 22:15:17 +0100 Subject: [PATCH] Migrate covers to external files dir. Fix #647 --- app/build.gradle | 2 +- .../eu/kanade/tachiyomi/data/cache/CoverCache.kt | 2 +- .../tachiyomi/ui/main/ChangelogDialogFragment.kt | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index fab46c019..96c100c84 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -38,7 +38,7 @@ android { minSdkVersion 16 targetSdkVersion 25 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - versionCode 18 + versionCode 19 versionName "0.4.2" buildConfigField "String", "COMMIT_COUNT", "\"${getCommitCount()}\"" diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/cache/CoverCache.kt b/app/src/main/java/eu/kanade/tachiyomi/data/cache/CoverCache.kt index ca7a1de50..dee208e0c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/cache/CoverCache.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/cache/CoverCache.kt @@ -20,7 +20,7 @@ class CoverCache(private val context: Context) { /** * Cache directory used for cache management. */ - private val cacheDir: File = File(context.externalCacheDir, "cover_disk_cache") + private val cacheDir = context.getExternalFilesDir("covers") /** * Returns the cover from cache. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/ChangelogDialogFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/ChangelogDialogFragment.kt index db7eee11b..08ab144b1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/ChangelogDialogFragment.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/ChangelogDialogFragment.kt @@ -39,6 +39,18 @@ class ChangelogDialogFragment : DialogFragment() { // Delete internal chapter cache dir. File(context.cacheDir, "chapter_disk_cache").deleteRecursively() } + if (oldVersion < 19) { + // Move covers to external files dir. + val oldDir = File(context.externalCacheDir, "cover_disk_cache") + if (oldDir.exists()) { + val destDir = context.getExternalFilesDir("covers") + if (destDir != null) { + oldDir.listFiles().forEach { + it.renameTo(File(destDir, it.name)) + } + } + } + } } } }