From a032e3d472442971459e15cce672e2b95d65b25c Mon Sep 17 00:00:00 2001 From: Graham Date: Tue, 14 Jan 2020 22:07:39 +0000 Subject: [PATCH] Exclude CRC from the path used by Resource::write --- bundler/src/main/java/dev/openrs2/bundler/Resource.kt | 8 +++++--- .../dev/openrs2/bundler/transform/ResourceTransformer.kt | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/bundler/src/main/java/dev/openrs2/bundler/Resource.kt b/bundler/src/main/java/dev/openrs2/bundler/Resource.kt index 7b031ecff8..cd801d354a 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/Resource.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/Resource.kt @@ -12,10 +12,14 @@ import java.util.zip.Deflater class Resource( val source: String, val destination: String, + val crc: Int, val digest: ByteArray, val uncompressedSize: Int, val content: ByteArray ) { + val sourceWithCrc: String + get() = source.replace(".", "_$crc.") + val compressedSize: Int get() = content.size @@ -36,8 +40,6 @@ class Resource( val crc = CRC32() crc.update(uncompressed) - val sourceWithCrc = source.replace(".", "_${crc.value.toInt()}.") - val digest = MessageDigest.getInstance("SHA-1") digest.update(uncompressed) @@ -59,7 +61,7 @@ class Resource( uncompressed } - return Resource(sourceWithCrc, destination, digest.digest(), uncompressed.size, content) + return Resource(source, destination, crc.value.toInt(), digest.digest(), uncompressed.size, content) } fun compressJar(source: String, destination: String, library: Library): Resource { diff --git a/bundler/src/main/java/dev/openrs2/bundler/transform/ResourceTransformer.kt b/bundler/src/main/java/dev/openrs2/bundler/transform/ResourceTransformer.kt index 9419c92151..5f57bf103d 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/transform/ResourceTransformer.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/transform/ResourceTransformer.kt @@ -112,7 +112,7 @@ class ResourceTransformer( list.add(TypeInsnNode(Opcodes.NEW, type)) list.add(InsnNode(Opcodes.DUP)) list.add(LdcInsnNode(resource.destination)) - list.add(LdcInsnNode(resource.source)) + list.add(LdcInsnNode(resource.sourceWithCrc)) list.add(createIntConstant(messages.size)) list.add(TypeInsnNode(Opcodes.ANEWARRAY, "java/lang/String"))