Exclude CRC from the path used by Resource::write

master
Graham 5 years ago
parent d03d1c3bb5
commit a032e3d472
  1. 8
      bundler/src/main/java/dev/openrs2/bundler/Resource.kt
  2. 2
      bundler/src/main/java/dev/openrs2/bundler/transform/ResourceTransformer.kt

@ -12,10 +12,14 @@ import java.util.zip.Deflater
class Resource( class Resource(
val source: String, val source: String,
val destination: String, val destination: String,
val crc: Int,
val digest: ByteArray, val digest: ByteArray,
val uncompressedSize: Int, val uncompressedSize: Int,
val content: ByteArray val content: ByteArray
) { ) {
val sourceWithCrc: String
get() = source.replace(".", "_$crc.")
val compressedSize: Int val compressedSize: Int
get() = content.size get() = content.size
@ -36,8 +40,6 @@ class Resource(
val crc = CRC32() val crc = CRC32()
crc.update(uncompressed) crc.update(uncompressed)
val sourceWithCrc = source.replace(".", "_${crc.value.toInt()}.")
val digest = MessageDigest.getInstance("SHA-1") val digest = MessageDigest.getInstance("SHA-1")
digest.update(uncompressed) digest.update(uncompressed)
@ -59,7 +61,7 @@ class Resource(
uncompressed 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 { fun compressJar(source: String, destination: String, library: Library): Resource {

@ -112,7 +112,7 @@ class ResourceTransformer(
list.add(TypeInsnNode(Opcodes.NEW, type)) list.add(TypeInsnNode(Opcodes.NEW, type))
list.add(InsnNode(Opcodes.DUP)) list.add(InsnNode(Opcodes.DUP))
list.add(LdcInsnNode(resource.destination)) list.add(LdcInsnNode(resource.destination))
list.add(LdcInsnNode(resource.source)) list.add(LdcInsnNode(resource.sourceWithCrc))
list.add(createIntConstant(messages.size)) list.add(createIntConstant(messages.size))
list.add(TypeInsnNode(Opcodes.ANEWARRAY, "java/lang/String")) list.add(TypeInsnNode(Opcodes.ANEWARRAY, "java/lang/String"))

Loading…
Cancel
Save