@ -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 )
}
}