This commit is contained in:
tom5079
2021-01-18 21:50:21 +09:00
parent 619730e2ab
commit 2f16838e1e
5 changed files with 5 additions and 10 deletions

View File

@@ -19,6 +19,7 @@
package xyz.quaver.pupil.util
import android.content.Context
import android.util.Log
import com.google.firebase.crashlytics.FirebaseCrashlytics
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.BufferOverflow
@@ -49,7 +50,7 @@ class ImageCache(context: Context) : DIAware {
suspend fun cleanup() = coroutineScope {
val LIMIT = 100*1024*1024
cacheFolder.listFiles { it -> it.canonicalPath !in cache }?.forEach { it.delete() }
cacheFolder.listFiles { it -> it.canonicalPath !in cache.values }?.forEach { it.delete() }
if (cacheFolder.size() > LIMIT)
do {

View File

@@ -35,7 +35,6 @@ class SavedSet <T: Any> (private val file: File, any: T, private val set: Mutabl
init {
if (!file.exists()) {
file.parentFile?.mkdirs()
save()
}
load()
@@ -53,6 +52,7 @@ class SavedSet <T: Any> (private val file: File, any: T, private val set: Mutabl
@Synchronized
fun save() {
file.parentFile?.mkdirs()
if (!file.exists())
file.createNewFile()
@@ -102,7 +102,6 @@ class SavedMap <K: Any, V: Any> (private val file: File, anyKey: K, anyValue: V,
init {
if (!file.exists()) {
file.parentFile?.mkdirs()
save()
}
load()
@@ -120,6 +119,7 @@ class SavedMap <K: Any, V: Any> (private val file: File, anyKey: K, anyValue: V,
@Synchronized
fun save() {
file.parentFile?.mkdirs()
if (!file.exists())
file.createNewFile()