From 3eefa3df52ef64837334a5dc49af162d35fb7fb8 Mon Sep 17 00:00:00 2001 From: Graham Date: Fri, 22 Apr 2022 10:53:48 +0100 Subject: [PATCH] Fix downloading caches A few pieces of code hadn't been correctly modified to deal with scopes. Signed-off-by: Graham --- .../org/openrs2/archive/cache/CacheImporter.kt | 13 ++++++++----- .../org/openrs2/archive/cache/Js5ChannelHandler.kt | 3 ++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/archive/src/main/kotlin/org/openrs2/archive/cache/CacheImporter.kt b/archive/src/main/kotlin/org/openrs2/archive/cache/CacheImporter.kt index 9bdc88bd30..99c193883e 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/cache/CacheImporter.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/cache/CacheImporter.kt @@ -283,6 +283,7 @@ public class CacheImporter @Inject constructor( buf: ByteBuf, uncompressed: ByteBuf, gameId: Int, + scopeId: Int, buildMajor: Int, buildMinor: Int?, lastId: Int?, @@ -337,13 +338,14 @@ public class CacheImporter @Inject constructor( FROM master_index_archives a LEFT JOIN master_index_archives a2 ON a2.master_index_id = ? AND a2.archive_id = a.archive_id AND a2.crc32 = a.crc32 AND a2.version = a.version - LEFT JOIN resolve_index(a2.archive_id, a2.crc32, a2.version) c ON TRUE + LEFT JOIN resolve_index(?, a2.archive_id, a2.crc32, a2.version) c ON TRUE WHERE a.master_index_id = ? ORDER BY a.archive_id ASC """.trimIndent() ).use { stmt -> stmt.setObject(1, lastId, Types.INTEGER) - stmt.setInt(2, masterIndexId) + stmt.setInt(2, scopeId) + stmt.setInt(3, masterIndexId) stmt.executeQuery().use { rows -> val indexes = mutableListOf() @@ -396,17 +398,18 @@ public class CacheImporter @Inject constructor( SELECT ig.group_id FROM index_groups ig LEFT JOIN resolved_indexes i ON i.master_index_id = ? AND - i.archive_id = ? + i.archive_id = ? AND i.scope_id = ? LEFT JOIN index_groups ig2 ON ig2.container_id = i.container_id AND ig2.group_id = ig.group_id AND ig2.crc32 = ig.crc32 AND ig2.version = ig.version - LEFT JOIN resolve_group(i.archive_id, ig2.group_id, ig2.crc32, ig2.version) c ON TRUE + LEFT JOIN resolve_group(i.scope_id, i.archive_id, ig2.group_id, ig2.crc32, ig2.version) c ON TRUE WHERE ig.container_id = ? AND c.id IS NULL ORDER BY ig.group_id ASC """.trimIndent() ).use { stmt -> stmt.setObject(1, lastMasterIndexId, Types.INTEGER) stmt.setInt(2, archive) - stmt.setLong(3, id) + stmt.setInt(3, scopeId) + stmt.setLong(4, id) stmt.executeQuery().use { rows -> val groups = mutableListOf() diff --git a/archive/src/main/kotlin/org/openrs2/archive/cache/Js5ChannelHandler.kt b/archive/src/main/kotlin/org/openrs2/archive/cache/Js5ChannelHandler.kt index 6155d9e623..c627664f09 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/cache/Js5ChannelHandler.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/cache/Js5ChannelHandler.kt @@ -237,7 +237,7 @@ public abstract class Js5ChannelHandler( if (groups.size >= CacheImporter.BATCH_SIZE || complete) { runBlocking { - importer.importGroups(sourceId, scopeId, groups) + importer.importGroups(scopeId, sourceId, groups) } releaseGroups() @@ -269,6 +269,7 @@ public abstract class Js5ChannelHandler( buf, uncompressed, gameId, + scopeId, buildMajor, buildMinor, lastMasterIndexId,