Use int for master index ids consistently

Signed-off-by: Graham <gpe@openrs2.org>
Graham 4 years ago
parent 5d8f89e319
commit 2aab020e67
  1. 12
      archive/src/main/kotlin/org/openrs2/archive/cache/CacheExporter.kt
  2. 4
      archive/src/main/kotlin/org/openrs2/archive/cache/ExportCommand.kt
  3. 4
      archive/src/main/kotlin/org/openrs2/archive/web/CachesController.kt

@ -18,7 +18,7 @@ public class CacheExporter @Inject constructor(
private val alloc: ByteBufAllocator private val alloc: ByteBufAllocator
) { ) {
public data class Cache( public data class Cache(
val id: Long, val id: Int,
val game: String, val game: String,
val build: Int?, val build: Int?,
val timestamp: Instant?, val timestamp: Instant?,
@ -49,7 +49,7 @@ public class CacheExporter @Inject constructor(
val caches = mutableListOf<Cache>() val caches = mutableListOf<Cache>()
while (rows.next()) { while (rows.next()) {
val id = rows.getLong(1) val id = rows.getInt(1)
val game = rows.getString(2) val game = rows.getString(2)
var build: Int? = rows.getInt(3) var build: Int? = rows.getInt(3)
@ -69,7 +69,7 @@ public class CacheExporter @Inject constructor(
} }
} }
public suspend fun export(id: Long, store: Store) { public suspend fun export(id: Int, store: Store) {
database.execute { connection -> database.execute { connection ->
connection.prepareStatement( connection.prepareStatement(
""" """
@ -79,7 +79,7 @@ public class CacheExporter @Inject constructor(
""".trimIndent() """.trimIndent()
).use { stmt -> ).use { stmt ->
stmt.fetchSize = BATCH_SIZE stmt.fetchSize = BATCH_SIZE
stmt.setLong(1, id) stmt.setInt(1, id)
stmt.executeQuery().use { rows -> stmt.executeQuery().use { rows ->
alloc.buffer(2, 2).use { versionBuf -> alloc.buffer(2, 2).use { versionBuf ->
@ -110,7 +110,7 @@ public class CacheExporter @Inject constructor(
} }
} }
public suspend fun exportKeys(id: Long): List<Key> { public suspend fun exportKeys(id: Int): List<Key> {
return database.execute { connection -> return database.execute { connection ->
connection.prepareStatement( connection.prepareStatement(
""" """
@ -121,7 +121,7 @@ public class CacheExporter @Inject constructor(
WHERE v.master_index_id = ? WHERE v.master_index_id = ?
""".trimIndent() """.trimIndent()
).use { stmt -> ).use { stmt ->
stmt.setLong(1, id) stmt.setInt(1, id)
stmt.executeQuery().use { rows -> stmt.executeQuery().use { rows ->
val keys = mutableListOf<Key>() val keys = mutableListOf<Key>()

@ -2,7 +2,7 @@ package org.openrs2.archive.cache
import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.arguments.argument import com.github.ajalt.clikt.parameters.arguments.argument
import com.github.ajalt.clikt.parameters.types.long import com.github.ajalt.clikt.parameters.types.int
import com.github.ajalt.clikt.parameters.types.path import com.github.ajalt.clikt.parameters.types.path
import com.google.inject.Guice import com.google.inject.Guice
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
@ -10,7 +10,7 @@ import org.openrs2.archive.ArchiveModule
import org.openrs2.cache.DiskStore import org.openrs2.cache.DiskStore
public class ExportCommand : CliktCommand(name = "export") { public class ExportCommand : CliktCommand(name = "export") {
private val id by argument().long() private val id by argument().int()
private val output by argument().path( private val output by argument().path(
mustExist = true, mustExist = true,
canBeFile = false, canBeFile = false,

@ -27,7 +27,7 @@ public class CachesController @Inject constructor(
} }
public suspend fun export(call: ApplicationCall) { public suspend fun export(call: ApplicationCall) {
val id = call.parameters["id"]?.toLongOrNull() val id = call.parameters["id"]?.toIntOrNull()
if (id == null) { if (id == null) {
call.respond(HttpStatusCode.NotFound) call.respond(HttpStatusCode.NotFound)
return return
@ -48,7 +48,7 @@ public class CachesController @Inject constructor(
} }
public suspend fun exportKeys(call: ApplicationCall) { public suspend fun exportKeys(call: ApplicationCall) {
val id = call.parameters["id"]?.toLongOrNull() val id = call.parameters["id"]?.toIntOrNull()
if (id == null) { if (id == null) {
call.respond(HttpStatusCode.NotFound) call.respond(HttpStatusCode.NotFound)
return return

Loading…
Cancel
Save