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 <gpe@openrs2.org>
Graham 4 years ago
parent e565b0cb4f
commit 4ca9bcb6d2
  1. 2
      archive/src/main/kotlin/org/openrs2/archive/cache/CacheDownloader.kt
  2. 12
      archive/src/main/kotlin/org/openrs2/archive/cache/CacheImporter.kt
  3. 12
      archive/src/main/kotlin/org/openrs2/archive/cache/Js5ChannelHandler.kt
  4. 2
      archive/src/main/kotlin/org/openrs2/archive/game/Game.kt
  5. 8
      archive/src/main/kotlin/org/openrs2/archive/game/GameDatabase.kt
  6. 2
      archive/src/main/resources/org/openrs2/archive/V1__init.sql

@ -30,7 +30,7 @@ public class CacheDownloader @Inject constructor(
hostname,
port,
build,
game.previousMasterIndexId,
game.lastMasterIndexId,
continuation,
importer
)

@ -169,7 +169,7 @@ public class CacheImporter @Inject constructor(
uncompressed: ByteBuf,
gameId: Int,
build: Int,
previousId: Int?,
lastId: Int?,
timestamp: Instant,
name: String,
): Pair<Int, List<ByteBuf?>> {
@ -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<Int> {
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)

@ -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<Unit>,
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<Js5Request.Group>()
private val pendingRequests = ArrayDeque<Js5Request.Group>()
private var currentMasterIndexId: Int = 0
private var masterIndexId: Int = 0
private var masterIndex: Js5MasterIndex? = null
private lateinit var indexes: Array<Js5Index?>
private val groups = mutableListOf<CacheImporter.Group>()
@ -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)

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

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

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

Loading…
Cancel
Save