From 8b70bb42909434a5e59315502f6d54d7c7691f18 Mon Sep 17 00:00:00 2001 From: Lucaskyy Date: Fri, 8 Apr 2022 23:50:26 +0200 Subject: [PATCH] fix: applyPatches not returning successful patches --- src/main/kotlin/app/revanced/patcher/Patcher.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/app/revanced/patcher/Patcher.kt b/src/main/kotlin/app/revanced/patcher/Patcher.kt index 0d710e66..b140ee68 100644 --- a/src/main/kotlin/app/revanced/patcher/Patcher.kt +++ b/src/main/kotlin/app/revanced/patcher/Patcher.kt @@ -3,6 +3,7 @@ package app.revanced.patcher import app.revanced.patcher.cache.Cache import app.revanced.patcher.extensions.replace import app.revanced.patcher.patch.Patch +import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.signature.resolver.SignatureResolver import app.revanced.patcher.signature.MethodSignature import lanchon.multidexlib2.BasicDexFileNamer @@ -79,13 +80,16 @@ class Patcher( * Apply patches loaded into the patcher. * @param stopOnError If true, the patches will stop on the first error. */ - fun applyPatches(stopOnError: Boolean = false): Map> { + fun applyPatches(stopOnError: Boolean = false): Map> { return buildMap { for (patch in patches) { - val result: Result = try { + val result: Result = try { val pr = patch.execute(cache) - if (pr.isSuccess()) continue - Result.failure(Exception(pr.error()?.errorMessage() ?: "Unknown error")) + if (!pr.isSuccess()) { + Result.success(pr) + } else { + Result.failure(Exception(pr.error()?.errorMessage() ?: "Unknown error")) + } } catch (e: Exception) { Result.failure(e) }