Migrate covers to external files dir. Fix #647

This commit is contained in:
len 2017-01-26 22:15:17 +01:00
parent 05c628b33c
commit e25ce768bb
3 changed files with 14 additions and 2 deletions

View file

@ -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()}\""

View file

@ -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.

View file

@ -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))
}
}
}
}
}
}
}