don't write all file if not requested

This commit is contained in:
Bixilon 2022-04-25 14:47:47 +02:00
parent 2c43a2ab59
commit 7d7d468b58
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -40,7 +40,7 @@ object PixLyzer {
try {
Class.forName("net.minecraft.DetectedVersion")
throw IllegalStateException("This branch only works with yarn mappings, not with mojangs!")
throw IllegalStateException("This branch only works with yarn mappings, not with mojangs!")
} catch (exception: ClassNotFoundException) {
}
@ -95,21 +95,16 @@ object PixLyzer {
println("Done generating ${generator.name} in ${System.currentTimeMillis() - startTime}ms, generated ${generator.entries} entries.")
}
println("Writing all to file...")
writData("${outputDirectory.absolutePath}/all", all)
println("Eventually writing all to file...")
val tempFileOutputPath = System.getProperty("java.io.tmpdir") + "/" + UUID.randomUUID().toString()
val jsonHash = Util.saveHashFile(all.toJsonString().byteInputStream(), tempFileOutputPath, GZIPOutputStream(FileOutputStream(tempFileOutputPath)), hashDirectory.absolutePath + "/\${shortHash}/\${hash}.gz")
val mbfStream = ByteArrayOutputStream()
MBFBinaryWriter(mbfStream).writeMBF(MBFData(dataInfo = MBFDataInfo(compression = MBFCompressionTypes.ZSDT, preferVariableTypes = true, variableLengthPrefix = true, compressionLevel = 22), data = all))
val mbfHash = Util.saveHashFile(ByteArrayInputStream(mbfStream.toByteArray()), tempFileOutputPath, FileOutputStream(tempFileOutputPath), hashDirectory.absolutePath + "/\${shortHash}/\${hash}.mbf")
if (File(jsonAssetsIndex.absolutePath + ".json").exists()) {
writData("${outputDirectory.absolutePath}/all", all)
val jsonHash = Util.saveHashFile(all.toJsonString().byteInputStream(), tempFileOutputPath, GZIPOutputStream(FileOutputStream(tempFileOutputPath)), hashDirectory.absolutePath + "/\${shortHash}/\${hash}.gz")
val assetsIndexJson = Util.readJsonFile(jsonAssetsIndex.absolutePath + ".json")
assetsIndexJson[versionId] = jsonHash
@ -120,6 +115,11 @@ object PixLyzer {
}
if (File(mbfAssetsIndex.absolutePath + ".json").exists()) {
val mbfStream = ByteArrayOutputStream()
MBFBinaryWriter(mbfStream).writeMBF(MBFData(dataInfo = MBFDataInfo(compression = MBFCompressionTypes.ZSDT, preferVariableTypes = true, variableLengthPrefix = true, compressionLevel = 22), data = all))
val mbfHash = Util.saveHashFile(ByteArrayInputStream(mbfStream.toByteArray()), tempFileOutputPath, FileOutputStream(tempFileOutputPath), hashDirectory.absolutePath + "/\${shortHash}/\${hash}.mbf")
val assetsIndexData = Util.readJsonFile(mbfAssetsIndex.absolutePath + ".json")