Skip to content

Commit

Permalink
fix: applyPatches not returning successful patches
Browse files Browse the repository at this point in the history
  • Loading branch information
Sculas authored and oSumAtrIX committed Jun 5, 2022
1 parent 6c3e2d7 commit f806cb3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main/kotlin/app/revanced/patcher/Patcher.kt
Expand Up @@ -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
Expand Down Expand Up @@ -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<String, Result<Nothing?>> {
fun applyPatches(stopOnError: Boolean = false): Map<String, Result<PatchResult>> {
return buildMap {
for (patch in patches) {
val result: Result<Nothing?> = try {
val result: Result<PatchResult> = 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)
}
Expand Down

0 comments on commit f806cb3

Please sign in to comment.