fix: removing a Proton also deletes its stored component originals

This commit is contained in:
maxjivi05 authored and MaxsTechReview committed 2026-10-24 08:22:00 -04:00
1 parent 0b671b2144
commit ad6d8d824a
3 files changed
+43 -1

No files matched your search

@@ -780,6 +780,17 @@ object ComponentsManager {
true
}
fun forgetProton(context: Context, dirName: String) {
synchronized(lock) {
val id = safeName(dirName)
if (protons(context).any { it.id == id }) return
val state = loadState(context)
val selected = listOf("active", "queued").map { state.sub(it).remove(id) != null }.any { it }
if (selected && runCatching { saveState(context, state) }.onFailure { Log.w(TAG, "forget $id", it) }.isFailure) return
File(originalsDir(context), id).deleteRecursively()
}
}
fun deletePackage(context: Context, file: String): String = synchronized(lock) {
val name = safeName(file)
val state = loadState(context)
@@ -137,10 +137,14 @@ object ProtonExtras {
fun remove(context: Context, tool: Tool, dir: String? = null) {
val name = if (dir != null) dir.takeIf { it in installedAll(context, tool) } ?: return else installed(context, tool) ?: return
File(toolsDir(context), name).deleteRecursively()
ComponentsManager.forgetProton(context, name)
}
fun removeOlder(context: Context, tool: Tool) {
installedAll(context, tool).dropLast(1).forEach { File(toolsDir(context), it).deleteRecursively() }
installedAll(context, tool).dropLast(1).forEach {
File(toolsDir(context), it).deleteRecursively()
ComponentsManager.forgetProton(context, it)
}
}
@Synchronized