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
) {
public data class Cache(
val id: Long,
val id: Int,
val game: String,
val build: Int?,
val timestamp: Instant?,
@ -49,7 +49,7 @@ public class CacheExporter @Inject constructor(
val caches = mutableListOf<Cache>()
while (rows.next()) {
val id = rows.getLong(1)
val id = rows.getInt(1)
val game = rows.getString(2)
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 ->
connection.prepareStatement(
"""
@ -79,7 +79,7 @@ public class CacheExporter @Inject constructor(
""".trimIndent()
).use { stmt ->
stmt.fetchSize = BATCH_SIZE
stmt.setLong(1, id)
stmt.setInt(1, id)
stmt.executeQuery().use { rows ->
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 ->
connection.prepareStatement(
"""
@ -121,7 +121,7 @@ public class CacheExporter @Inject constructor(
WHERE v.master_index_id = ?
""".trimIndent()
).use { stmt ->
stmt.setLong(1, id)
stmt.setInt(1, id)
stmt.executeQuery().use { rows ->
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.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.google.inject.Guice
import kotlinx.coroutines.runBlocking
@ -10,7 +10,7 @@ import org.openrs2.archive.ArchiveModule
import org.openrs2.cache.DiskStore
public class ExportCommand : CliktCommand(name = "export") {
private val id by argument().long()
private val id by argument().int()
private val output by argument().path(
mustExist = true,
canBeFile = false,

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

Loading…
Cancel
Save