From 80ae3403407915a7e0cd51077be411839f6ec9ad Mon Sep 17 00:00:00 2001 From: Jordan Date: Mon, 27 Sep 2021 21:54:01 -0400 Subject: [PATCH 1/7] Cache loading improvements. --- .../cache/hierarchy/ReferenceTable.kt | 73 ++++++++++++------- .../com/runetopic/cache/store/Js5Store.kt | 1 + .../runetopic/cache/store/storage/IStorage.kt | 4 +- .../cache/store/storage/js5/Js5DiskStorage.kt | 53 +++++++------- .../cache/store/storage/js5/impl/DatFile.kt | 8 +- .../cache/store/storage/js5/impl/IdxFile.kt | 11 ++- 6 files changed, 84 insertions(+), 66 deletions(-) diff --git a/cache/src/main/kotlin/com/runetopic/cache/hierarchy/ReferenceTable.kt b/cache/src/main/kotlin/com/runetopic/cache/hierarchy/ReferenceTable.kt index 94dbaae..e381282 100644 --- a/cache/src/main/kotlin/com/runetopic/cache/hierarchy/ReferenceTable.kt +++ b/cache/src/main/kotlin/com/runetopic/cache/hierarchy/ReferenceTable.kt @@ -1,6 +1,6 @@ package com.runetopic.cache.hierarchy -import com.runetopic.cache.codec.ContainerCodec +import com.runetopic.cache.codec.Container import com.runetopic.cache.codec.decompress import com.runetopic.cache.exception.ProtocolException import com.runetopic.cache.extension.readUnsignedByte @@ -59,31 +59,49 @@ internal data class ReferenceTable( fun exists(): Boolean = (length != 0 && sector != 0) - fun loadIndex(datFile: IDatFile, idxFile: IIdxFile, whirlpool: ByteArray, data: ByteArray): Js5Index { - val container = ContainerCodec.decompress(data) - val buffer = ByteBuffer.wrap(container.data) + fun loadIndex( + datFile: IDatFile, + idxFile: IIdxFile, + whirlpool: ByteArray, + decompressed: Container + ): Js5Index { + val buffer = ByteBuffer.wrap(decompressed.data) + val crc = decompressed.crc + val compressionType = decompressed.compression val protocol = buffer.readUnsignedByte() - var revision = 0 - - if (protocol < 5 || protocol > 6) { - throw ProtocolException("Unhandled protocol $protocol when reading index $this") + val revision = when { + protocol < 5 || protocol > 6 -> throw ProtocolException("Unhandled protocol $protocol when reading index $this") + protocol == 6 -> buffer.int + else -> 0 } - - if (protocol >= 6) { - revision = buffer.int + val hash = buffer.readUnsignedByte() + val count = buffer.readUnsignedShort() + val groupTables = mutableListOf() + (0 until count).forEach { + groupTables.add(datFile.readReferenceTable(idxFile.id(), idxFile.loadReferenceTable(it))) } + return loadIndexContents(idxFile.id(), buffer, crc, compressionType, revision, protocol, hash, count, whirlpool, groupTables) + } + + private fun loadIndexContents( + indexId: Int, + buffer: ByteBuffer, + crc: Int, + compressionType: Int, + revision: Int, + protocol: Int, + hash: Int, + count: Int, + whirlpool: ByteArray, + groupTables: List + ): Js5Index { + val groupIds = IntArray(count) - val hash = buffer.readUnsignedByte() val isNamed = (0x1 and hash) != 0 val isUsingWhirlPool = (0x2 and hash) != 0 - val count = buffer.readUnsignedShort() - var lastGroupId = 0 var biggest = -1 - - val groupIds = IntArray(count) - (0 until count).forEach { groupIds[it] = buffer.readUnsignedShort().let { id -> lastGroupId += id; lastGroupId } if (groupIds[it] > biggest) biggest = groupIds[it] @@ -101,7 +119,6 @@ internal data class ReferenceTable( val groups = hashMapOf() (0 until count).forEach { val groupId = groupIds[it] - val groupReferenceTable = datFile.readReferenceTable(idxFile.id(), idxFile.loadReferenceTable(it)) groups[it] = (Js5Group( id = groupId, nameHash = groupNameHashes[groupId], @@ -109,11 +126,11 @@ internal data class ReferenceTable( whirlpool = groupWhirlpools[groupId], revision = groupRevisions[groupId], keys = intArrayOf(), - files = files(fileIds, fileNameHashes, groupReferenceTable, groupFileIds[it], it), - data = groupReferenceTable + files = files(fileIds, fileNameHashes, groupTables[it], groupFileIds[it], it), + data = groupTables[it] )) } - return Js5Index(idxFile.id(), container.crc, whirlpool, container.compression, protocol, revision, isNamed, groups) + return Js5Index(indexId, crc, whirlpool, compressionType, protocol, revision, isNamed, groups) } private fun groupFileIds( @@ -195,8 +212,8 @@ internal data class ReferenceTable( count: Int, groupIds: IntArray, buffer: ByteBuffer - ): Array> { - val fileIds = Array(largestGroupId) { Array(validFileIds[it]) { -1 } } + ): Array { + val fileIds = Array(largestGroupId) { IntArray(validFileIds[it]) } (0 until count).forEach { val groupId = groupIds[it] var currentFileId = 0 @@ -216,8 +233,8 @@ internal data class ReferenceTable( groupIds: IntArray, buffer: ByteBuffer, isNamed: Boolean - ): Array> { - val fileNameHashes = Array(largestGroupId) { Array(validFileIds[it]) { -1 } } + ): Array { + val fileNameHashes = Array(largestGroupId) { IntArray(validFileIds[it]) } if (isNamed) { (0 until count).forEach { val groupId = groupIds[it] @@ -230,8 +247,8 @@ internal data class ReferenceTable( } private fun files( - fileIds: Array>, - fileNameHashes: Array>, + fileIds: Array, + fileNameHashes: Array, groupReferenceTableData: ByteArray, count: Int, groupId: Int @@ -249,7 +266,7 @@ internal data class ReferenceTable( } var position = src.size - val chunks: Int = src[--position].toInt() and 0xFF + val chunks = src[--position].toInt() and 0xFF position -= chunks * (count * 4) val buffer = ByteBuffer.wrap(src) buffer.position(position) diff --git a/cache/src/main/kotlin/com/runetopic/cache/store/Js5Store.kt b/cache/src/main/kotlin/com/runetopic/cache/store/Js5Store.kt index 4091608..4d4f814 100644 --- a/cache/src/main/kotlin/com/runetopic/cache/store/Js5Store.kt +++ b/cache/src/main/kotlin/com/runetopic/cache/store/Js5Store.kt @@ -1,6 +1,7 @@ package com.runetopic.cache.store import com.runetopic.cache.hierarchy.index.Index +import com.runetopic.cache.store.Constants import com.runetopic.cache.store.storage.js5.Js5DiskStorage import com.runetopic.cryptography.ext.toWhirlpool import java.io.Closeable diff --git a/cache/src/main/kotlin/com/runetopic/cache/store/storage/IStorage.kt b/cache/src/main/kotlin/com/runetopic/cache/store/storage/IStorage.kt index 38c64bc..51402c4 100644 --- a/cache/src/main/kotlin/com/runetopic/cache/store/storage/IStorage.kt +++ b/cache/src/main/kotlin/com/runetopic/cache/store/storage/IStorage.kt @@ -1,10 +1,10 @@ package com.runetopic.cache.store.storage -import com.runetopic.cache.hierarchy.ReferenceTable import com.runetopic.cache.hierarchy.index.Index import com.runetopic.cache.store.Js5Store import java.io.Closeable import java.io.Flushable +import java.util.concurrent.CountDownLatch /** * @author Tyler Telis @@ -12,7 +12,7 @@ import java.io.Flushable */ internal interface IStorage: Closeable, Flushable { fun init(store: Js5Store) - fun loadIndex(table: ReferenceTable, indexId: Int, whirlpool: ByteArray, referenceTable: ByteArray): Index + fun store(indexId: Int, store: Js5Store, latch: CountDownLatch) fun loadReferenceTable(index: Index, groupId: Int): ByteArray fun loadMasterReferenceTable(groupId: Int): ByteArray fun loadReferenceTable(index: Index, groupName: String): ByteArray diff --git a/cache/src/main/kotlin/com/runetopic/cache/store/storage/js5/Js5DiskStorage.kt b/cache/src/main/kotlin/com/runetopic/cache/store/storage/js5/Js5DiskStorage.kt index c169cf4..d9cd48b 100644 --- a/cache/src/main/kotlin/com/runetopic/cache/store/storage/js5/Js5DiskStorage.kt +++ b/cache/src/main/kotlin/com/runetopic/cache/store/storage/js5/Js5DiskStorage.kt @@ -1,8 +1,8 @@ package com.runetopic.cache.store.storage.js5 import com.github.michaelbull.logging.InlineLogger +import com.runetopic.cache.codec.ContainerCodec import com.runetopic.cache.extension.whirlpool -import com.runetopic.cache.hierarchy.ReferenceTable import com.runetopic.cache.hierarchy.index.Index import com.runetopic.cache.hierarchy.index.Js5Index import com.runetopic.cache.store.Constants @@ -10,7 +10,6 @@ import com.runetopic.cache.store.Js5Store import com.runetopic.cache.store.storage.IStorage import com.runetopic.cache.store.storage.js5.impl.DatFile import com.runetopic.cache.store.storage.js5.impl.IdxFile -import java.io.File import java.io.FileNotFoundException import java.nio.ByteBuffer import java.nio.file.Path @@ -18,11 +17,14 @@ import java.util.concurrent.CountDownLatch import java.util.concurrent.ExecutorService import java.util.concurrent.Executors import java.util.concurrent.TimeUnit +import kotlin.io.path.ExperimentalPathApi +import kotlin.io.path.exists /** * @author Tyler Telis * @email */ +@OptIn(ExperimentalPathApi::class) internal class Js5DiskStorage( private val path: Path ) : IStorage { @@ -32,13 +34,13 @@ internal class Js5DiskStorage( private val logger = InlineLogger() init { - val masterIndexFile = File("${path}/${Constants.MAIN_FILE_255}") + val masterIndexFile = Path.of("${path}/${Constants.MAIN_FILE_255}") if (masterIndexFile.exists().not()) { throw FileNotFoundException("Missing ${Constants.MAIN_FILE_255} in directory ${path}/${Constants.MAIN_FILE_255}") } - val datFile = File("${path}/${Constants.MAIN_FILE_DAT}") + val datFile = Path.of("${path}/${Constants.MAIN_FILE_DAT}") if (datFile.exists().not()) { throw FileNotFoundException("Missing ${Constants.MAIN_FILE_DAT} in directory ${path}/${Constants.MAIN_FILE_DAT}") @@ -56,34 +58,29 @@ internal class Js5DiskStorage( } val latch = CountDownLatch(masterIdxFile.validIndexCount()) - (0 until masterIdxFile.validIndexCount()).forEach { - val referenceTable = masterIdxFile.loadReferenceTable(it) - idxFiles.add(getIdxFile(it)) - - if (referenceTable.exists().not()) { - store.addIndex(Js5Index.default(it)) - latch.countDown() - return@forEach - } - val datTable = datFile.readReferenceTable(masterIdxFile.id(), referenceTable) - - pool?.let { service -> - service.execute { - store.addIndex(loadIndex(referenceTable, it, ByteBuffer.wrap(datTable).whirlpool(), datTable)) - latch.countDown() - } - } ?: run { - store.addIndex(loadIndex(referenceTable, it, ByteBuffer.wrap(datTable).whirlpool(), datTable)) - latch.countDown() - } + (0 until masterIdxFile.validIndexCount()).forEach { indexId -> + pool?.let { it.execute { store(indexId, store, latch) } } + ?: run { store(indexId, store, latch) } } + latch.await(60, TimeUnit.SECONDS) pool?.shutdown() - logger.debug { "Loaded ${idxFiles.size} indices." } + logger.debug { "Loaded ${idxFiles.size} indexes." } } - override fun loadIndex(table: ReferenceTable, indexId: Int, whirlpool: ByteArray, referenceTable: ByteArray): Js5Index { - return table.loadIndex(datFile, getIdxFile(indexId), whirlpool, referenceTable) + override fun store(indexId: Int, store: Js5Store, latch: CountDownLatch) { + val indexTable = masterIdxFile.loadReferenceTable(indexId) + idxFiles.add(getIdxFile(indexId)) + + if (indexTable.exists().not()) { + store.addIndex(Js5Index.default(indexId)) + latch.countDown() + return + } + + val indexDatTable = datFile.readReferenceTable(masterIdxFile.id(), indexTable) + store.addIndex(indexTable.loadIndex(datFile, getIdxFile(indexId), ByteBuffer.wrap(indexDatTable).whirlpool(), ContainerCodec.decompress(indexDatTable))) + latch.countDown() } override fun loadMasterReferenceTable(groupId: Int): ByteArray { @@ -102,7 +99,7 @@ internal class Js5DiskStorage( private fun getIdxFile(id: Int): IdxFile { idxFiles.find { it.id() == id }?.let { return it } - return IdxFile(id, File("$path/${Constants.MAIN_FILE_IDX}${id}")) + return IdxFile(id, Path.of("$path/${Constants.MAIN_FILE_IDX}${id}")) } override fun close() { diff --git a/cache/src/main/kotlin/com/runetopic/cache/store/storage/js5/impl/DatFile.kt b/cache/src/main/kotlin/com/runetopic/cache/store/storage/js5/impl/DatFile.kt index 02b6266..e36f9f6 100644 --- a/cache/src/main/kotlin/com/runetopic/cache/store/storage/js5/impl/DatFile.kt +++ b/cache/src/main/kotlin/com/runetopic/cache/store/storage/js5/impl/DatFile.kt @@ -5,18 +5,18 @@ import com.runetopic.cache.exception.EndOfDatFileException import com.runetopic.cache.hierarchy.ReferenceTable import com.runetopic.cache.store.Constants.SECTOR_SIZE import com.runetopic.cache.store.storage.js5.IDatFile -import java.io.File import java.io.RandomAccessFile import java.nio.ByteBuffer +import java.nio.file.Path /** * @author Tyler Telis * @email */ internal class DatFile( - file: File + path: Path ): IDatFile { - private val datFile: RandomAccessFile = RandomAccessFile(file, "rw") + private val datFile: RandomAccessFile = RandomAccessFile(path.toFile(), "rw") @Synchronized override fun readReferenceTable(id: Int, referenceTable: ReferenceTable): ByteArray { @@ -107,7 +107,7 @@ internal class DatFile( currentId: Int, ) { if (referenceTableId != currentReferenceTableId || currentPart != part || id != currentId) { - throw DatFileException("DataFile mismatch Id={${currentId}} != {${id}}, ReferenceTableId={${currentReferenceTableId}} != {${referenceTableId}}, CurrentPart={${currentPart}} != {${part}}") + throw DatFileException("DataFile mismatch Id={${currentId}} != {${id}}, ReferenceTableId={${currentReferenceTableId}} != {${referenceTableId}}, CurrentPart={${currentPart}} != {${part}}") } } diff --git a/cache/src/main/kotlin/com/runetopic/cache/store/storage/js5/impl/IdxFile.kt b/cache/src/main/kotlin/com/runetopic/cache/store/storage/js5/impl/IdxFile.kt index 67252b1..98bd34a 100644 --- a/cache/src/main/kotlin/com/runetopic/cache/store/storage/js5/impl/IdxFile.kt +++ b/cache/src/main/kotlin/com/runetopic/cache/store/storage/js5/impl/IdxFile.kt @@ -3,8 +3,10 @@ package com.runetopic.cache.store.storage.js5.impl import com.runetopic.cache.exception.IdxFileException import com.runetopic.cache.hierarchy.ReferenceTable import com.runetopic.cache.store.storage.js5.IIdxFile -import java.io.File import java.io.RandomAccessFile +import java.nio.file.Path +import kotlin.io.path.ExperimentalPathApi +import kotlin.io.path.fileSize /** * @author Tyler Telis @@ -12,9 +14,9 @@ import java.io.RandomAccessFile */ internal class IdxFile( private val id: Int, - private val file: File + private val path: Path ) : IIdxFile { - private val idxFile: RandomAccessFile = RandomAccessFile(file, "rw") + private val idxFile: RandomAccessFile = RandomAccessFile(path.toFile(), "rw") private val readBuffer = ByteArray(ENTRY_LIMIT) @Synchronized @@ -44,7 +46,8 @@ internal class IdxFile( } } - override fun validIndexCount(): Int = file.length().toInt() / ENTRY_LIMIT + @OptIn(ExperimentalPathApi::class) + override fun validIndexCount(): Int = path.fileSize().toInt() / ENTRY_LIMIT override fun id(): Int = id override fun close() = idxFile.close() From 04ad1159bada4d87371c5e71be298764f59025b8 Mon Sep 17 00:00:00 2001 From: Jordan Date: Tue, 28 Sep 2021 16:36:26 -0400 Subject: [PATCH 2/7] Make the Index list sorted and fix an issue with whirlpool in getting checksums with rsa. --- .../kotlin/com/runetopic/cache/store/Js5Store.kt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cache/src/main/kotlin/com/runetopic/cache/store/Js5Store.kt b/cache/src/main/kotlin/com/runetopic/cache/store/Js5Store.kt index 4d4f814..51d50c8 100644 --- a/cache/src/main/kotlin/com/runetopic/cache/store/Js5Store.kt +++ b/cache/src/main/kotlin/com/runetopic/cache/store/Js5Store.kt @@ -1,10 +1,10 @@ package com.runetopic.cache.store import com.runetopic.cache.hierarchy.index.Index -import com.runetopic.cache.store.Constants import com.runetopic.cache.store.storage.js5.Js5DiskStorage import com.runetopic.cryptography.ext.toWhirlpool import java.io.Closeable +import java.lang.System.arraycopy import java.math.BigInteger import java.nio.ByteBuffer import java.nio.file.Path @@ -27,7 +27,8 @@ class Js5Store( internal fun addIndex(index: Index) { indexes.forEach { i -> require(index.getId() != i.getId()) { "Index with Id={${index.getId()}} already exists." } } - this.indexes.add(index) + indexes.add(index) + indexes.sortWith(compareBy { it.getId() }) } fun index(indexId: Int): Index = this.indexes.find { it.getId() == indexId }!! @@ -78,12 +79,14 @@ class Js5Store( val whirlpool = ByteBuffer.allocate(64 + 1) whirlpool.put(1) - whirlpool.put(ByteBuffer.wrap(headerArray, 5, headerPosition - 5).array().toWhirlpool()) - val rsa = BigInteger(whirlpool.array()).modPow(exponent, modulus).toByteArray() + val whirlpoolArray = ByteArray(headerPosition - 5) + arraycopy(headerArray, 5, whirlpoolArray, 0, headerPosition - 5) + whirlpool.put(whirlpoolArray.toWhirlpool()) - val checksums = ByteBuffer.allocate(headerPosition.plus(rsa.size)) + val rsa = BigInteger(whirlpool.array()).modPow(exponent, modulus).toByteArray() + val checksums = ByteBuffer.allocate(headerPosition + rsa.size) checksums.put(0) - checksums.putInt((headerPosition.plus(rsa.size)) - 5) + checksums.putInt((headerPosition + rsa.size) - 5) checksums.put(headerArray, 5, headerPosition - 5) checksums.put(rsa) return checksums.array() From 54d60d4c534b8ad8833cfb10e48931855fc443e7 Mon Sep 17 00:00:00 2001 From: Jordan Date: Tue, 28 Sep 2021 16:37:20 -0400 Subject: [PATCH 3/7] Bump cache version. --- cache/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cache/build.gradle.kts b/cache/build.gradle.kts index 2a1936f..21dc711 100644 --- a/cache/build.gradle.kts +++ b/cache/build.gradle.kts @@ -4,7 +4,7 @@ plugins { signing } -version = "1.4.8-SNAPSHOT" +version = "1.4.9-SNAPSHOT" java { withJavadocJar() From 28fec84ea1500bdb4559565652a8d74569ce8406 Mon Sep 17 00:00:00 2001 From: Jordan Date: Tue, 28 Sep 2021 16:43:30 -0400 Subject: [PATCH 4/7] Fix a parallel thread issue with sorting the indexes list inside Js5Store. --- README.md | 2 +- cache/src/main/kotlin/com/runetopic/cache/store/Js5Store.kt | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ac4f248..cd00bc3 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ A cache library written in Kotlin. # Implementation Just use cache if you do not require any of the revision specific loaders. ``` -cache = { module = "com.runetopic.cache:cache", version.ref "1.4.7-SNAPSHOT" } +cache = { module = "com.runetopic.cache:cache", version.ref "1.4.9-SNAPSHOT" } loader = { module = "com.runetopic.cache:loader", version.ref "647.6.1-SNAPSHOT" } //For the SNAPSHOTS diff --git a/cache/src/main/kotlin/com/runetopic/cache/store/Js5Store.kt b/cache/src/main/kotlin/com/runetopic/cache/store/Js5Store.kt index 51d50c8..87f10ca 100644 --- a/cache/src/main/kotlin/com/runetopic/cache/store/Js5Store.kt +++ b/cache/src/main/kotlin/com/runetopic/cache/store/Js5Store.kt @@ -22,16 +22,16 @@ class Js5Store( private val indexes = arrayListOf() init { - this.storage.init(this) + storage.init(this) + indexes.sortWith(compareBy { it.getId() }) } internal fun addIndex(index: Index) { indexes.forEach { i -> require(index.getId() != i.getId()) { "Index with Id={${index.getId()}} already exists." } } indexes.add(index) - indexes.sortWith(compareBy { it.getId() }) } - fun index(indexId: Int): Index = this.indexes.find { it.getId() == indexId }!! + fun index(indexId: Int): Index = indexes.find { it.getId() == indexId }!! fun indexReferenceTableSize(indexId: Int): Int { var size = 0 From 1c4238730e33822432c93045d475f6823d0f33fb Mon Sep 17 00:00:00 2001 From: Jordan Date: Tue, 28 Sep 2021 16:51:14 -0400 Subject: [PATCH 5/7] Minor update to checksumsWithRSA function inside Js5Store. --- cache/src/main/kotlin/com/runetopic/cache/store/Js5Store.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cache/src/main/kotlin/com/runetopic/cache/store/Js5Store.kt b/cache/src/main/kotlin/com/runetopic/cache/store/Js5Store.kt index 87f10ca..f6891ee 100644 --- a/cache/src/main/kotlin/com/runetopic/cache/store/Js5Store.kt +++ b/cache/src/main/kotlin/com/runetopic/cache/store/Js5Store.kt @@ -79,9 +79,7 @@ class Js5Store( val whirlpool = ByteBuffer.allocate(64 + 1) whirlpool.put(1) - val whirlpoolArray = ByteArray(headerPosition - 5) - arraycopy(headerArray, 5, whirlpoolArray, 0, headerPosition - 5) - whirlpool.put(whirlpoolArray.toWhirlpool()) + whirlpool.put(headerArray.copyInto(ByteArray(headerPosition - 5), 0, 5, headerPosition).toWhirlpool()) val rsa = BigInteger(whirlpool.array()).modPow(exponent, modulus).toByteArray() val checksums = ByteBuffer.allocate(headerPosition + rsa.size) From 224eac4342f84e0895a981a6d6b51261ca8fe304 Mon Sep 17 00:00:00 2001 From: Jordan Date: Wed, 29 Sep 2021 20:48:25 -0400 Subject: [PATCH 6/7] Update to latest Runetopic cryptography library. --- cache/build.gradle.kts | 2 +- .../main/kotlin/com/runetopic/cache/codec/ContainerCodec.kt | 2 +- .../main/kotlin/com/runetopic/cache/extension/ByteBuffer.kt | 2 +- cache/src/main/kotlin/com/runetopic/cache/store/Js5Store.kt | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cache/build.gradle.kts b/cache/build.gradle.kts index 21dc711..ec5a1ca 100644 --- a/cache/build.gradle.kts +++ b/cache/build.gradle.kts @@ -77,5 +77,5 @@ dependencies { implementation("com.michael-bull.kotlin-inline-logger:kotlin-inline-logger:1.0.3") implementation("org.slf4j:slf4j-simple:1.7.32") implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.+") - implementation("com.runetopic.cryptography:cryptography:1.0.2-SNAPSHOT") + implementation("com.runetopic.cryptography:cryptography:1.0.4-SNAPSHOT") } diff --git a/cache/src/main/kotlin/com/runetopic/cache/codec/ContainerCodec.kt b/cache/src/main/kotlin/com/runetopic/cache/codec/ContainerCodec.kt index 55743bd..d720994 100644 --- a/cache/src/main/kotlin/com/runetopic/cache/codec/ContainerCodec.kt +++ b/cache/src/main/kotlin/com/runetopic/cache/codec/ContainerCodec.kt @@ -4,7 +4,7 @@ import com.runetopic.cache.codec.CodecType.* import com.runetopic.cache.exception.CompressionException import com.runetopic.cache.extension.readUnsignedShort import com.runetopic.cache.extension.remainingBytes -import com.runetopic.cryptography.ext.fromXTEA +import com.runetopic.cryptography.fromXTEA import java.nio.ByteBuffer import java.util.zip.CRC32 diff --git a/cache/src/main/kotlin/com/runetopic/cache/extension/ByteBuffer.kt b/cache/src/main/kotlin/com/runetopic/cache/extension/ByteBuffer.kt index 0d554b4..40846d1 100644 --- a/cache/src/main/kotlin/com/runetopic/cache/extension/ByteBuffer.kt +++ b/cache/src/main/kotlin/com/runetopic/cache/extension/ByteBuffer.kt @@ -1,7 +1,7 @@ package com.runetopic.cache.extension import com.runetopic.cache.store.Constants.cp1252Identifiers -import com.runetopic.cryptography.ext.toWhirlpool +import com.runetopic.cryptography.toWhirlpool import java.nio.ByteBuffer import java.nio.charset.Charset diff --git a/cache/src/main/kotlin/com/runetopic/cache/store/Js5Store.kt b/cache/src/main/kotlin/com/runetopic/cache/store/Js5Store.kt index f6891ee..72fe2dd 100644 --- a/cache/src/main/kotlin/com/runetopic/cache/store/Js5Store.kt +++ b/cache/src/main/kotlin/com/runetopic/cache/store/Js5Store.kt @@ -2,9 +2,8 @@ package com.runetopic.cache.store import com.runetopic.cache.hierarchy.index.Index import com.runetopic.cache.store.storage.js5.Js5DiskStorage -import com.runetopic.cryptography.ext.toWhirlpool +import com.runetopic.cryptography.toWhirlpool import java.io.Closeable -import java.lang.System.arraycopy import java.math.BigInteger import java.nio.ByteBuffer import java.nio.file.Path @@ -26,6 +25,7 @@ class Js5Store( indexes.sortWith(compareBy { it.getId() }) } + @Synchronized internal fun addIndex(index: Index) { indexes.forEach { i -> require(index.getId() != i.getId()) { "Index with Id={${index.getId()}} already exists." } } indexes.add(index) From 394309273632b28c2e687d0066ff87b0cb8d7b17 Mon Sep 17 00:00:00 2001 From: Jordan Date: Wed, 29 Sep 2021 20:54:14 -0400 Subject: [PATCH 7/7] Bump version for cryptography updates/ --- README.md | 2 +- cache/build.gradle.kts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cd00bc3..a0020e6 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ A cache library written in Kotlin. # Implementation Just use cache if you do not require any of the revision specific loaders. ``` -cache = { module = "com.runetopic.cache:cache", version.ref "1.4.9-SNAPSHOT" } +cache = { module = "com.runetopic.cache:cache", version.ref "1.4.10-SNAPSHOT" } loader = { module = "com.runetopic.cache:loader", version.ref "647.6.1-SNAPSHOT" } //For the SNAPSHOTS diff --git a/cache/build.gradle.kts b/cache/build.gradle.kts index ec5a1ca..3debab0 100644 --- a/cache/build.gradle.kts +++ b/cache/build.gradle.kts @@ -4,7 +4,7 @@ plugins { signing } -version = "1.4.9-SNAPSHOT" +version = "1.4.10-SNAPSHOT" java { withJavadocJar()