Skip to content

Commit a022feb

Browse files
committed
fix: Delete temporal files if it exists
1 parent 978032c commit a022feb

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

revanced-cli/src/main/kotlin/app/revanced/cli/command/PatchCommand.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,10 @@ internal object PatchCommand : Runnable {
208208

209209
// region Save
210210

211-
val aligned = resourceCachePath.resolve(apk.name)
212-
ApkUtils.align(apk, aligned, patcherResult)
211+
val tempFile = resourceCachePath.resolve(apk.name)
212+
ApkUtils.copyAligned(apk, tempFile, patcherResult)
213213
if (!mount) ApkUtils.sign(
214-
aligned,
214+
tempFile,
215215
outputFilePath,
216216
SigningOptions(
217217
commonName,

revanced-lib/api/revanced-lib.api

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
public final class app/revanced/lib/ApkUtils {
22
public static final field INSTANCE Lapp/revanced/lib/ApkUtils;
3-
public final fun align (Ljava/io/File;Ljava/io/File;Lapp/revanced/patcher/PatcherResult;)V
3+
public final fun copyAligned (Ljava/io/File;Ljava/io/File;Lapp/revanced/patcher/PatcherResult;)V
44
public final fun sign (Ljava/io/File;Ljava/io/File;Lapp/revanced/lib/signing/SigningOptions;)V
55
}
66

@@ -98,7 +98,7 @@ public final class app/revanced/lib/signing/SigningOptions {
9898

9999
public final class app/revanced/lib/zip/ZipAligner {
100100
public static final field INSTANCE Lapp/revanced/lib/zip/ZipAligner;
101-
public final fun getEntryAlignment (Lapp/revanced/lib/zip/structures/ZipEntry;)Ljava/lang/Integer;
101+
public final fun getApkZipEntryAlignment ()Lkotlin/jvm/functions/Function1;
102102
}
103103

104104
public final class app/revanced/lib/zip/ZipFile : java/io/Closeable {

revanced-lib/src/main/kotlin/app/revanced/lib/ApkUtils.kt

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import app.revanced.lib.zip.structures.ZipEntry
88
import app.revanced.patcher.PatcherResult
99
import java.io.File
1010
import java.util.logging.Logger
11+
import kotlin.io.path.deleteIfExists
1112

1213
@Suppress("MemberVisibilityCanBePrivate", "unused")
1314
object ApkUtils {
@@ -20,9 +21,11 @@ object ApkUtils {
2021
* @param outputFile The apk to write the new entries to.
2122
* @param patchedEntriesSource The result of the patcher to add the patched dex files and resources.
2223
*/
23-
fun align(apkFile: File, outputFile: File, patchedEntriesSource: PatcherResult) {
24+
fun copyAligned(apkFile: File, outputFile: File, patchedEntriesSource: PatcherResult) {
2425
logger.info("Aligning ${apkFile.name}")
2526

27+
outputFile.toPath().deleteIfExists()
28+
2629
ZipFile(outputFile).use { file ->
2730
patchedEntriesSource.dexFiles.forEach {
2831
file.addEntryCompressData(

0 commit comments

Comments
 (0)