From 2aab020e67f30f16c2d6640d46c0d508256caf0b Mon Sep 17 00:00:00 2001 From: Graham Date: Thu, 11 Feb 2021 21:35:31 +0000 Subject: [PATCH] Use int for master index ids consistently Signed-off-by: Graham --- .../org/openrs2/archive/cache/CacheExporter.kt | 12 ++++++------ .../org/openrs2/archive/cache/ExportCommand.kt | 4 ++-- .../org/openrs2/archive/web/CachesController.kt | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/archive/src/main/kotlin/org/openrs2/archive/cache/CacheExporter.kt b/archive/src/main/kotlin/org/openrs2/archive/cache/CacheExporter.kt index bdada10f..0559e8e9 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/cache/CacheExporter.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/cache/CacheExporter.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() 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 { + public suspend fun exportKeys(id: Int): List { 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() diff --git a/archive/src/main/kotlin/org/openrs2/archive/cache/ExportCommand.kt b/archive/src/main/kotlin/org/openrs2/archive/cache/ExportCommand.kt index 15086609..efb7f98c 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/cache/ExportCommand.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/cache/ExportCommand.kt @@ -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, diff --git a/archive/src/main/kotlin/org/openrs2/archive/web/CachesController.kt b/archive/src/main/kotlin/org/openrs2/archive/web/CachesController.kt index 998ec8ce..7e1a7919 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/web/CachesController.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/web/CachesController.kt @@ -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