From 97640774f91b450876815a7b3bdf954671d1f0d5 Mon Sep 17 00:00:00 2001 From: Graham Date: Sun, 7 Feb 2021 01:11:43 +0000 Subject: [PATCH] Store index protocol, version and flags in the database Although it isn't necessary, we might as well as it doesn't take up much extra space and we already store all the properties for all groups and files. Signed-off-by: Graham --- .../org/openrs2/archive/cache/CacheImporter.kt | 12 ++++++++++-- .../main/resources/org/openrs2/archive/V1__init.sql | 8 +++++++- 2 files changed, 17 insertions(+), 3 deletions(-) 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 41d861dee1..db96f6068e 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/cache/CacheImporter.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/cache/CacheImporter.kt @@ -563,11 +563,19 @@ public class CacheImporter @Inject constructor( connection.prepareStatement( """ - INSERT INTO indexes (container_id) - VALUES (?) + INSERT INTO indexes ( + container_id, protocol, version, has_names, has_digests, has_lengths, has_uncompressed_checksums + ) + VALUES (?, ?, ?, ?, ?, ?, ?) """.trimIndent() ).use { stmt -> stmt.setLong(1, containerId) + stmt.setInt(2, index.index.protocol.id) + stmt.setInt(3, index.index.version) + stmt.setBoolean(4, index.index.hasNames) + stmt.setBoolean(5, index.index.hasDigests) + stmt.setBoolean(6, index.index.hasLengths) + stmt.setBoolean(7, index.index.hasUncompressedChecksums) try { stmt.execute() 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 9c9dfc5db8..18ce60506d 100644 --- a/archive/src/main/resources/org/openrs2/archive/V1__init.sql +++ b/archive/src/main/resources/org/openrs2/archive/V1__init.sql @@ -57,7 +57,13 @@ CREATE TABLE groups ( ); CREATE TABLE indexes ( - container_id BIGINT PRIMARY KEY NOT NULL REFERENCES containers (id) + container_id BIGINT PRIMARY KEY NOT NULL REFERENCES containers (id), + protocol uint1 NOT NULL, + version INTEGER NOT NULL, + has_names BOOLEAN NOT NULL, + has_digests BOOLEAN NOT NULL, + has_lengths BOOLEAN NOT NULL, + has_uncompressed_checksums BOOLEAN NOT NULL ); CREATE TABLE index_groups (