From 22d2535af8b3ea8fa58b6beb2938d240afa0a17d Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sat, 11 Jun 2022 19:56:45 +0200 Subject: [PATCH] fix: sign the aligned file instead of the input file --- .../kotlin/app/revanced/cli/signing/Signing.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/app/revanced/cli/signing/Signing.kt b/src/main/kotlin/app/revanced/cli/signing/Signing.kt index f314c08..f6c9e24 100644 --- a/src/main/kotlin/app/revanced/cli/signing/Signing.kt +++ b/src/main/kotlin/app/revanced/cli/signing/Signing.kt @@ -7,17 +7,18 @@ import java.io.File object Signing { fun start(inputFile: File, outputFile: File, cn: String, password: String) { - // align & sign val cacheDirectory = File(cacheDirectory) val alignedOutput = cacheDirectory.resolve("aligned.apk") val signedOutput = cacheDirectory.resolve("signed.apk") - ZipAligner.align(inputFile, alignedOutput) - Signer( - cn, - password - ).signApk(inputFile, signedOutput) - // write to output + // align the inputFile and write to alignedOutput + ZipAligner.align(inputFile, alignedOutput) + // sign the alignedOutput and write to signedOutput + // the reason is, in case the signer fails + // it does not damage the output file + Signer(cn, password).signApk(alignedOutput, signedOutput) + + // afterwards copy over the file to the output signedOutput.copyTo(outputFile) } }