Add processGroup method to Js5ChanneHandler

This is consistent with processMasterIndex and processIndex,
particularly now that the processGroup logic is slightly more
complicated.

Signed-off-by: Graham <gpe@openrs2.org>
Graham 4 years ago
parent 06ff7a9d3b
commit 692ca20344
  1. 34
      archive/src/main/kotlin/org/openrs2/archive/cache/Js5ChannelHandler.kt

@ -129,21 +129,7 @@ public class Js5ChannelHandler(
} else if (response.archive == Js5Archive.ARCHIVESET) { } else if (response.archive == Js5Archive.ARCHIVESET) {
processIndex(response.group, response.data) processIndex(response.group, response.data)
} else { } else {
val entry = indexes[response.archive]!![response.group]!! processGroup(response.archive, response.group, response.data)
if (response.data.crc32() != entry.checksum) {
throw Exception("Group checksum invalid")
}
val uncompressed = Js5Compression.uncompressUnlessEncrypted(response.data.slice())
groups += CacheImporter.Group(
response.archive,
response.group,
response.data.retain(),
uncompressed,
entry.version,
versionTruncated = false
)
} }
val complete = pendingRequests.isEmpty() && inFlightRequests.isEmpty() val complete = pendingRequests.isEmpty() && inFlightRequests.isEmpty()
@ -224,6 +210,24 @@ public class Js5ChannelHandler(
} }
} }
private fun processGroup(archive: Int, group: Int, buf: ByteBuf) {
val entry = indexes[archive]!![group]!!
if (buf.crc32() != entry.checksum) {
throw Exception("Group checksum invalid")
}
val uncompressed = Js5Compression.uncompressUnlessEncrypted(buf.slice())
groups += CacheImporter.Group(
archive,
group,
buf.retain(),
uncompressed,
entry.version,
versionTruncated = false
)
}
private fun request(archive: Int, group: Int) { private fun request(archive: Int, group: Int) {
pendingRequests += Js5Request.Group(false, archive, group) pendingRequests += Js5Request.Group(false, archive, group)
} }

Loading…
Cancel
Save