mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2024-11-10 09:08:04 +01:00
fix: applyPatches not returning successful patches
This commit is contained in:
parent
dbda641d0c
commit
8b70bb4290
1 changed files with 8 additions and 4 deletions
|
@ -3,6 +3,7 @@ package app.revanced.patcher
|
||||||
import app.revanced.patcher.cache.Cache
|
import app.revanced.patcher.cache.Cache
|
||||||
import app.revanced.patcher.extensions.replace
|
import app.revanced.patcher.extensions.replace
|
||||||
import app.revanced.patcher.patch.Patch
|
import app.revanced.patcher.patch.Patch
|
||||||
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.signature.resolver.SignatureResolver
|
import app.revanced.patcher.signature.resolver.SignatureResolver
|
||||||
import app.revanced.patcher.signature.MethodSignature
|
import app.revanced.patcher.signature.MethodSignature
|
||||||
import lanchon.multidexlib2.BasicDexFileNamer
|
import lanchon.multidexlib2.BasicDexFileNamer
|
||||||
|
@ -79,13 +80,16 @@ class Patcher(
|
||||||
* Apply patches loaded into the patcher.
|
* Apply patches loaded into the patcher.
|
||||||
* @param stopOnError If true, the patches will stop on the first error.
|
* @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 {
|
return buildMap {
|
||||||
for (patch in patches) {
|
for (patch in patches) {
|
||||||
val result: Result<Nothing?> = try {
|
val result: Result<PatchResult> = try {
|
||||||
val pr = patch.execute(cache)
|
val pr = patch.execute(cache)
|
||||||
if (pr.isSuccess()) continue
|
if (!pr.isSuccess()) {
|
||||||
Result.failure(Exception(pr.error()?.errorMessage() ?: "Unknown error"))
|
Result.success(pr)
|
||||||
|
} else {
|
||||||
|
Result.failure(Exception(pr.error()?.errorMessage() ?: "Unknown error"))
|
||||||
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Result.failure(e)
|
Result.failure(e)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue