From ea9ec62e6e03cbc104ca9dfcbbf983f2e9b90125 Mon Sep 17 00:00:00 2001 From: Graham Date: Mon, 2 Jan 2023 20:25:11 +0000 Subject: [PATCH] Add support for fetching master index from the API Signed-off-by: Graham --- .../openrs2/archive/cache/CacheExporter.kt | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/archive/src/main/kotlin/org/openrs2/archive/cache/CacheExporter.kt b/archive/src/main/kotlin/org/openrs2/archive/cache/CacheExporter.kt index cc3c969e5d..13a306697e 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/cache/CacheExporter.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/cache/CacheExporter.kt @@ -588,6 +588,26 @@ public class CacheExporter @Inject constructor( public suspend fun exportGroup(scope: String, id: Int, archive: Int, group: Int): ByteBuf? { return database.execute { connection -> + if (archive == Store.ARCHIVESET && group == Store.ARCHIVESET) { + connection.prepareStatement( + """ + SELECT c.data + FROM master_indexes m + JOIN containers c ON c.id = m.container_id + WHERE m.id = ? + """.trimIndent() + ).use { stmt -> + stmt.setInt(1, id) + + stmt.executeQuery().use { rows -> + if (rows.next()) { + val data = rows.getBytes(1) + return@execute Unpooled.wrappedBuffer(data) + } + } + } + } + connection.prepareStatement( """ SELECT g.data