From 4ca9bcb6d2388538840d610a27871b98adb66194 Mon Sep 17 00:00:00 2001 From: Graham Date: Fri, 12 Feb 2021 00:22:31 +0000 Subject: [PATCH] Rename master_index_id to last_master_index_id This is consistent with last_container_id and last_key_id in brute_force_iterator. Signed-off-by: Graham --- .../org/openrs2/archive/cache/CacheDownloader.kt | 2 +- .../org/openrs2/archive/cache/CacheImporter.kt | 12 ++++++------ .../org/openrs2/archive/cache/Js5ChannelHandler.kt | 12 ++++++------ .../src/main/kotlin/org/openrs2/archive/game/Game.kt | 2 +- .../kotlin/org/openrs2/archive/game/GameDatabase.kt | 8 ++++---- .../main/resources/org/openrs2/archive/V1__init.sql | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/archive/src/main/kotlin/org/openrs2/archive/cache/CacheDownloader.kt b/archive/src/main/kotlin/org/openrs2/archive/cache/CacheDownloader.kt index 1fb8380878..7836c5b848 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/cache/CacheDownloader.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/cache/CacheDownloader.kt @@ -30,7 +30,7 @@ public class CacheDownloader @Inject constructor( hostname, port, build, - game.previousMasterIndexId, + game.lastMasterIndexId, continuation, importer ) 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 f572b98fe2..246c88d806 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/cache/CacheImporter.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/cache/CacheImporter.kt @@ -169,7 +169,7 @@ public class CacheImporter @Inject constructor( uncompressed: ByteBuf, gameId: Int, build: Int, - previousId: Int?, + lastId: Int?, timestamp: Instant, name: String, ): Pair> { @@ -222,7 +222,7 @@ public class CacheImporter @Inject constructor( ORDER BY a.archive_id ASC """.trimIndent() ).use { stmt -> - stmt.setObject(1, previousId, Types.INTEGER) + stmt.setObject(1, lastId, Types.INTEGER) stmt.setInt(2, id) stmt.executeQuery().use { rows -> @@ -252,7 +252,7 @@ public class CacheImporter @Inject constructor( index: Js5Index, buf: ByteBuf, uncompressed: ByteBuf, - previousMasterIndexId: Int? + lastMasterIndexId: Int? ): List { return database.execute { connection -> prepare(connection) @@ -284,7 +284,7 @@ public class CacheImporter @Inject constructor( ORDER BY ig.group_id ASC """.trimIndent() ).use { stmt -> - stmt.setObject(1, previousMasterIndexId, Types.INTEGER) + stmt.setObject(1, lastMasterIndexId, Types.INTEGER) stmt.setInt(2, archive) stmt.setLong(3, id) @@ -770,11 +770,11 @@ public class CacheImporter @Inject constructor( } } - public suspend fun setMasterIndexId(gameId: Int, masterIndexId: Int) { + public suspend fun setLastMasterIndexId(gameId: Int, masterIndexId: Int) { database.execute { connection -> connection.prepareStatement( """ - UPDATE games SET master_index_id = ? WHERE id = ? + UPDATE games SET last_master_index_id = ? WHERE id = ? """.trimIndent() ).use { stmt -> stmt.setInt(1, masterIndexId) 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 7c7d2835d7..937c834716 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/cache/Js5ChannelHandler.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/cache/Js5ChannelHandler.kt @@ -35,7 +35,7 @@ public class Js5ChannelHandler( private val hostname: String, private val port: Int, private var build: Int, - private val previousMasterIndexId: Int?, + private val lastMasterIndexId: Int?, private val continuation: Continuation, private val importer: CacheImporter, private val masterIndexFormat: MasterIndexFormat = MasterIndexFormat.VERSIONED, @@ -45,7 +45,7 @@ public class Js5ChannelHandler( private val maxBuild = build + maxBuildAttempts private val inFlightRequests = mutableSetOf() private val pendingRequests = ArrayDeque() - private var currentMasterIndexId: Int = 0 + private var masterIndexId: Int = 0 private var masterIndex: Js5MasterIndex? = null private lateinit var indexes: Array private val groups = mutableListOf() @@ -144,7 +144,7 @@ public class Js5ChannelHandler( if (complete) { runBlocking { - importer.setMasterIndexId(gameId, currentMasterIndexId) + importer.setLastMasterIndexId(gameId, masterIndexId) } ctx.close() @@ -164,7 +164,7 @@ public class Js5ChannelHandler( uncompressed, gameId, build, - previousMasterIndexId, + lastMasterIndexId, timestamp = Instant.now(), name ) @@ -183,7 +183,7 @@ public class Js5ChannelHandler( rawIndexes.filterNotNull().forEach(ByteBuf::release) } - currentMasterIndexId = id + masterIndexId = id } } @@ -202,7 +202,7 @@ public class Js5ChannelHandler( } val groups = runBlocking { - importer.importIndexAndGetMissingGroups(archive, index, buf, uncompressed, previousMasterIndexId) + importer.importIndexAndGetMissingGroups(archive, index, buf, uncompressed, lastMasterIndexId) } for (group in groups) { request(archive, group) diff --git a/archive/src/main/kotlin/org/openrs2/archive/game/Game.kt b/archive/src/main/kotlin/org/openrs2/archive/game/Game.kt index 16e3177de2..fc316cbb66 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/game/Game.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/game/Game.kt @@ -5,5 +5,5 @@ public data class Game( public val hostname: String?, public val port: Int?, public val build: Int?, - public val previousMasterIndexId: Int? + public val lastMasterIndexId: Int? ) diff --git a/archive/src/main/kotlin/org/openrs2/archive/game/GameDatabase.kt b/archive/src/main/kotlin/org/openrs2/archive/game/GameDatabase.kt index 9380febd7f..595a4036ae 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/game/GameDatabase.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/game/GameDatabase.kt @@ -12,7 +12,7 @@ public class GameDatabase @Inject constructor( return database.execute { connection -> connection.prepareStatement( """ - SELECT id, hostname, port, build, master_index_id + SELECT id, hostname, port, build, last_master_index_id FROM games WHERE name = ? """.trimIndent() @@ -37,12 +37,12 @@ public class GameDatabase @Inject constructor( build = null } - var masterIndexId: Int? = rows.getInt(5) + var lastMasterIndexId: Int? = rows.getInt(5) if (rows.wasNull()) { - masterIndexId = null + lastMasterIndexId = null } - return@execute Game(id, hostname, port, build, masterIndexId) + return@execute Game(id, hostname, port, build, lastMasterIndexId) } } } diff --git a/archive/src/main/resources/org/openrs2/archive/V1__init.sql b/archive/src/main/resources/org/openrs2/archive/V1__init.sql index de7a30101f..d6b1924e90 100644 --- a/archive/src/main/resources/org/openrs2/archive/V1__init.sql +++ b/archive/src/main/resources/org/openrs2/archive/V1__init.sql @@ -108,7 +108,7 @@ CREATE TABLE master_indexes ( UNIQUE (container_id, format) ); -ALTER TABLE games ADD COLUMN master_index_id INT NULL REFERENCES master_indexes (id); +ALTER TABLE games ADD COLUMN last_master_index_id INT NULL REFERENCES master_indexes (id); CREATE TABLE master_index_archives ( master_index_id INTEGER NOT NULL REFERENCES master_indexes (id),