Skip to content

Commit

Permalink
fix: check dependencies for resource patches
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Sep 29, 2022
1 parent 4383213 commit 9c07ffc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/main/kotlin/app/revanced/patcher/Patcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class Patcher(private val options: PatcherOptions) {
*/
fun Class<out Patch<Data>>.isResource() {
this.also {
if (!ResourcePatch::class.java.isAssignableFrom(it)) return
if (!ResourcePatch::class.java.isAssignableFrom(it)) return@also
// set the mode to decode all resources before running the patches
resourceDecodingMode = ResourceDecodingMode.FULL
}.dependencies?.forEach { it.java.isResource() }
Expand Down Expand Up @@ -249,14 +249,15 @@ class Patcher(private val options: PatcherOptions) {
}

// recursively apply all dependency patches
patch.dependencies?.forEach { dependency ->
val result = applyPatch(dependency.java, appliedPatches)
patch.dependencies?.forEach { dependencyClass ->
val dependency = dependencyClass.java

val result = applyPatch(dependency, appliedPatches)
if (result.isSuccess()) return@forEach

val error = result.error()!!
val errorMessage = error.cause ?: error.message
return PatchResultError("'$patchName' depends on '${patch.patchName}' but the following error was raised: $errorMessage")
return PatchResultError("'$patchName' depends on '${dependency.patchName}' but the following error was raised: $errorMessage")
}

patch.deprecated?.let { (reason, replacement) ->
Expand Down

0 comments on commit 9c07ffc

Please sign in to comment.