From 45d9b0a3c684f11d5fdc39b26d6945a2e182bc93 Mon Sep 17 00:00:00 2001 From: rushiiMachine <33725716+rushiiMachine@users.noreply.github.com> Date: Sun, 19 May 2024 13:42:42 -0700 Subject: [PATCH] feat: delete cache if patching fails --- .../com/aliucord/manager/installer/steps/StepRunner.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/kotlin/com/aliucord/manager/installer/steps/StepRunner.kt b/app/src/main/kotlin/com/aliucord/manager/installer/steps/StepRunner.kt index 21a706a..8168108 100644 --- a/app/src/main/kotlin/com/aliucord/manager/installer/steps/StepRunner.kt +++ b/app/src/main/kotlin/com/aliucord/manager/installer/steps/StepRunner.kt @@ -4,6 +4,7 @@ import android.content.Context import androidx.lifecycle.Lifecycle import androidx.lifecycle.ProcessLifecycleOwner import com.aliucord.manager.R +import com.aliucord.manager.installer.steps.base.DownloadStep import com.aliucord.manager.installer.steps.base.Step import com.aliucord.manager.manager.PreferencesManager import com.aliucord.manager.ui.util.InstallNotifications @@ -50,6 +51,14 @@ abstract class StepRunner : KoinComponent { val error = step.executeCatching(this@StepRunner) if (error != null) { showErrorNotification() + + // If this is a patch step and it failed, then clear download cache just in case + if (step.group == StepGroup.Patch && !preferences.devMode) { + for (downloadStep in steps.asSequence().filterIsInstance()) { + downloadStep.targetFile.delete() + } + } + return error }