fix: cache clearing
This commit is contained in:
parent
ff345fbcce
commit
4011177373
5 changed files with 15 additions and 7 deletions
|
|
@ -47,7 +47,8 @@ class PathManager(
|
|||
* Delete the entire cache dir and recreate it.
|
||||
*/
|
||||
fun clearCache() {
|
||||
cacheDir.deleteRecursively()
|
||||
context.cacheDir.deleteRecursively()
|
||||
context.externalCacheDir?.deleteRecursively()
|
||||
cacheDir.mkdirs()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ class PatchingScreen(private val data: PatchOptions) : Screen, Parcelable {
|
|||
),
|
||||
onClick = {
|
||||
cacheCleared = true
|
||||
model.cancelInstall()
|
||||
model.clearCache()
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,8 +62,6 @@ class PatchingScreenModel(
|
|||
}
|
||||
}
|
||||
|
||||
fun getCurrentInstallId(): String? = installId
|
||||
|
||||
fun launchApp() {
|
||||
if (state.value !is PatchingScreenState.Success)
|
||||
return
|
||||
|
|
@ -78,6 +76,13 @@ class PatchingScreenModel(
|
|||
}
|
||||
}
|
||||
|
||||
fun clearCache() = screenModelScope.launchBlock {
|
||||
paths.clearCache()
|
||||
application.showToast(R.string.action_cleared_cache)
|
||||
}
|
||||
|
||||
fun getCurrentInstallId(): String? = installId
|
||||
|
||||
fun cancelInstall() = screenModelScope.launchBlock(Dispatchers.IO) {
|
||||
runnerJob?.cancel("Manual cancellation")
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import androidx.compose.runtime.*
|
|||
import cafe.adriel.voyager.core.model.ScreenModel
|
||||
import cafe.adriel.voyager.core.model.screenModelScope
|
||||
import com.aliucord.manager.R
|
||||
import com.aliucord.manager.manager.PathManager
|
||||
import com.aliucord.manager.manager.PreferencesManager
|
||||
import com.aliucord.manager.ui.theme.Theme
|
||||
import com.aliucord.manager.util.launchBlock
|
||||
|
|
@ -14,6 +15,7 @@ import kotlinx.coroutines.launch
|
|||
|
||||
class SettingsModel(
|
||||
private val application: Application,
|
||||
private val paths: PathManager,
|
||||
val preferences: PreferencesManager,
|
||||
) : ScreenModel {
|
||||
var showThemeDialog by mutableStateOf(false)
|
||||
|
|
@ -44,8 +46,8 @@ class SettingsModel(
|
|||
preferences.keepPatchedApks = value
|
||||
}
|
||||
|
||||
fun clearCacheDir() = screenModelScope.launchBlock {
|
||||
application.externalCacheDir?.deleteRecursively()
|
||||
fun clearCache() = screenModelScope.launchBlock {
|
||||
paths.clearCache()
|
||||
application.showToast(R.string.action_cleared_cache)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ class SettingsScreen : Screen, Parcelable {
|
|||
),
|
||||
onClick = {
|
||||
clearedCache = true
|
||||
model.clearCacheDir()
|
||||
model.clearCache()
|
||||
},
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 18.dp, vertical = 10.dp)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue