mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2026-01-28 21:51:02 +00:00
fix: Patch should have access to the Cache
BREAKING CHANGE: Method signature of execute() was changed to include the cache, this will break existing implementations of the Patch class.
This commit is contained in:
@@ -23,7 +23,7 @@ class Patcher(
|
||||
private val patches: MutableList<Patch> = mutableListOf()
|
||||
|
||||
init {
|
||||
val classes = Io.readClassesFromJar(input);
|
||||
val classes = Io.readClassesFromJar(input)
|
||||
cache = Cache(classes, MethodResolver(classes, signatures).resolve())
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class Patcher(
|
||||
return buildMap {
|
||||
for (patch in patches) {
|
||||
val result: Result<Nothing?> = try {
|
||||
val pr = patch.execute()
|
||||
val pr = patch.execute(cache)
|
||||
if (pr.isSuccess()) continue
|
||||
Result.failure(Exception(pr.error()?.errorMessage() ?: "Unknown error"))
|
||||
} catch (e: Exception) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.revanced.patcher.patch
|
||||
|
||||
import net.revanced.patcher.cache.Cache
|
||||
|
||||
abstract class Patch(val patchName: String) {
|
||||
abstract fun execute(): PatchResult
|
||||
abstract fun execute(cache: Cache): PatchResult
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user