use of net.runelite.cache.fs.jagex.DiskStorage in project runelite by runelite.
the class ArchiveRequestHandler method handleRequest255.
private void handleRequest255(ChannelHandlerContext ctx, int index, int archiveId) throws IOException {
logger.info("Client {} requests 255: index {}, archive {}", ctx.channel().remoteAddress(), index, archiveId);
byte[] compressed;
if (archiveId == 255) {
// index 255 data, for each index:
// 4 byte crc
// 4 byte revision
ByteBuf buffer = ctx.alloc().heapBuffer(store.getIndexes().size() * 8);
for (Index i : store.getIndexes()) {
buffer.writeInt(i.getCrc());
buffer.writeInt(i.getRevision());
}
compressed = compress(CompressionType.NONE, Arrays.copyOf(buffer.array(), buffer.readableBytes()));
buffer.release();
} else {
// Requires disk storage. Use packed index data from
// store as its crc matches
DiskStorage storage = (DiskStorage) store.getStorage();
compressed = storage.readIndex(archiveId);
}
ArchiveResponsePacket response = new ArchiveResponsePacket();
response.setIndex(index);
response.setArchive(archiveId);
response.setData(compressed);
ctx.writeAndFlush(response);
}
Aggregations