Add groups and total_uncompressed_length to master_index_archives

This commit also adds support for populating the whirlpool column, and
ensures version is set to 0 for the ORIGINAL master index format.

Signed-off-by: Graham <gpe@openrs2.org>
Graham 4 years ago
parent 86f100ff4f
commit 2ac2ab8230
  1. 27
      archive/src/main/kotlin/org/openrs2/archive/cache/CacheImporter.kt
  2. 2
      archive/src/main/resources/org/openrs2/archive/V1__init.sql

@ -474,15 +474,36 @@ public class CacheImporter @Inject constructor(
connection.prepareStatement(
"""
INSERT INTO master_index_archives (master_index_id, archive_id, crc32, version)
VALUES (?, ?, ?, ?)
INSERT INTO master_index_archives (
master_index_id, archive_id, crc32, version, whirlpool, groups, total_uncompressed_length
)
VALUES (?, ?, ?, ?, ?, ?, ?)
""".trimIndent()
).use { stmt ->
for ((i, entry) in masterIndex.index.entries.withIndex()) {
stmt.setInt(1, masterIndexId!!)
stmt.setInt(2, i)
stmt.setInt(3, entry.checksum)
stmt.setInt(4, entry.version)
if (masterIndex.index.format >= MasterIndexFormat.VERSIONED) {
stmt.setInt(4, entry.version)
} else {
stmt.setInt(4, 0)
}
if (masterIndex.index.format >= MasterIndexFormat.DIGESTS) {
stmt.setBytes(5, entry.digest ?: ByteArray(Whirlpool.DIGESTBYTES))
} else {
stmt.setNull(5, Types.BINARY)
}
if (masterIndex.index.format >= MasterIndexFormat.LENGTHS) {
stmt.setInt(6, entry.groups)
stmt.setInt(7, entry.totalUncompressedLength)
} else {
stmt.setNull(6, Types.INTEGER)
stmt.setNull(7, Types.INTEGER)
}
stmt.addBatch()
}

@ -117,6 +117,8 @@ CREATE TABLE master_index_archives (
crc32 INTEGER NOT NULL,
whirlpool BYTEA NULL,
version INTEGER NOT NULL,
groups INTEGER NULL,
total_uncompressed_length INTEGER NULL,
PRIMARY KEY (master_index_id, archive_id)
);

Loading…
Cancel
Save