From 99a03f1152db58e5ad3d3ac635005fe7f9f25ba2 Mon Sep 17 00:00:00 2001 From: zani Date: Mon, 15 Jan 2024 02:04:09 -0700 Subject: [PATCH] include file hashes when figuring out cache location --- .../kotlin/wtf/zani/launchwrapper/LunarLaunchWrapper.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/wtf/zani/launchwrapper/LunarLaunchWrapper.kt b/src/main/kotlin/wtf/zani/launchwrapper/LunarLaunchWrapper.kt index 787abf5..3aea32a 100644 --- a/src/main/kotlin/wtf/zani/launchwrapper/LunarLaunchWrapper.kt +++ b/src/main/kotlin/wtf/zani/launchwrapper/LunarLaunchWrapper.kt @@ -71,8 +71,10 @@ suspend fun main(args: Array) { return } + var hashes: List? = null + withContext(Dispatchers.IO) { - launch { version.download(offlineDir) } + launch { hashes = version.download(offlineDir) } launch { textures.download(textureDir) } } @@ -124,6 +126,8 @@ suspend fun main(args: Array) { val digest = MessageDigest.getInstance("SHA-256") + hashes!!.forEach { digest.update(it.toByteArray()) } + PrebakeHelper.location = offlineDir.resolve("cache/${toHexString(digest.digest(gameVersion.toByteArray()))}") PrebakeHelper.location.createDirectories()