Fix auto cache cleanup
This commit is contained in:
@@ -38,7 +38,7 @@ android {
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 30
|
||||
versionCode 61
|
||||
versionName "5.1.2"
|
||||
versionName "5.1.2-hotfix2"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"filters": [],
|
||||
"properties": [],
|
||||
"versionCode": 61,
|
||||
"versionName": "5.1.2",
|
||||
"versionName": "5.1.2-hotfix2",
|
||||
"enabled": true,
|
||||
"outputFile": "app-release.apk"
|
||||
}
|
||||
|
||||
@@ -37,19 +37,11 @@ fun cleanCache(context: Context) = CoroutineScope(Dispatchers.IO).launch {
|
||||
val cacheFolder = File(context.cacheDir, "imageCache")
|
||||
val downloadManager = DownloadManager.getInstance(context)
|
||||
|
||||
cacheFolder.listFiles { file ->
|
||||
val galleryID = file.name.toIntOrNull() ?: return@listFiles true
|
||||
|
||||
!(downloadManager.downloadFolderMap.containsKey(galleryID) || histories.contains(galleryID))
|
||||
}?.forEach {
|
||||
it.deleteRecursively()
|
||||
}
|
||||
|
||||
DownloadManager.getInstance(context).downloadFolderMap.keys.forEach {
|
||||
val folder = File(cacheFolder, it.toString())
|
||||
|
||||
if (!downloadManager.isDownloading(it) && folder.exists()) {
|
||||
folder.deleteRecursively()
|
||||
Cache.delete(it)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user