mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2024-11-10 01:02:22 +01:00
fix: always return PatchResultSuccess on patch success
This commit is contained in:
parent
5b28523eea
commit
996c4acb20
1 changed files with 7 additions and 4 deletions
|
@ -2,7 +2,7 @@ package app.revanced.patcher
|
|||
|
||||
import app.revanced.patcher.cache.Cache
|
||||
import app.revanced.patcher.patch.Patch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.signature.resolver.SignatureResolver
|
||||
import app.revanced.patcher.signature.MethodSignature
|
||||
import app.revanced.patcher.util.ListBackedSet
|
||||
|
@ -99,15 +99,18 @@ class Patcher(
|
|||
/**
|
||||
* Apply patches loaded into the patcher.
|
||||
* @param stopOnError If true, the patches will stop on the first error.
|
||||
* @return A map of results. If the patch was successfully applied,
|
||||
* PatchResultSuccess will always be returned in the wrapping Result object.
|
||||
* If the patch failed to apply, an Exception will always be returned in the wrapping Result object.
|
||||
*/
|
||||
fun applyPatches(stopOnError: Boolean = false, callback: (String) -> Unit = {}): Map<String, Result<PatchResult>> {
|
||||
fun applyPatches(stopOnError: Boolean = false, callback: (String) -> Unit = {}): Map<String, Result<PatchResultSuccess>> {
|
||||
return buildMap {
|
||||
for (patch in patches) {
|
||||
callback(patch.patchName)
|
||||
val result: Result<PatchResult> = try {
|
||||
val result: Result<PatchResultSuccess> = try {
|
||||
val pr = patch.execute(cache)
|
||||
if (pr.isSuccess()) {
|
||||
Result.success(pr)
|
||||
Result.success(pr.success()!!)
|
||||
} else {
|
||||
Result.failure(Exception(pr.error()?.errorMessage() ?: "Unknown error"))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue