feat: clear old version caches
This commit is contained in:
parent
33ad23fb01
commit
9fbf465648
1 changed files with 10 additions and 0 deletions
|
|
@ -111,6 +111,14 @@ class InstallViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
private fun clearOldCache(targetVersion: Int) {
|
||||
externalCacheDir.listFiles { f -> f.isDirectory }
|
||||
?.map { it.name.toIntOrNull() to it }
|
||||
?.filter { it.first != null }
|
||||
?.filter { it.first!! in (126021 + 1) until targetVersion }
|
||||
?.forEach { it.second.deleteRecursively() }
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
if (installationRunning.getAndSet(false)) {
|
||||
installJob.cancel("ViewModel cleared")
|
||||
|
|
@ -141,6 +149,8 @@ class InstallViewModel(
|
|||
val discordCacheDir = externalCacheDir.resolve(supportedVersion)
|
||||
val patchedDir = discordCacheDir.resolve("patched").also { it.deleteRecursively() }
|
||||
|
||||
clearOldCache(supportedVersion.toInt())
|
||||
|
||||
// Download base.apk
|
||||
val baseApkFile = step(InstallStep.DL_BASE_APK) {
|
||||
discordCacheDir.resolve("base-${supportedVersion}.apk").let { file ->
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue