korge
korge copied to clipboard
Possible bug in korio: cannot uncompress valid GZIP file
Hey!
I have an sqlite database that was gzip compressed with korio, but when uncompressing it with korio I get the following error:
com.soywiz.korio.lang.InvalidOperationException: Size doesn't match SIZE(0x00040000 != 0x008A5ECD) || CRC32(0x8A5ECD41 != 0x41000400)
at com.soywiz.korio.lang.ExceptionsKt.invalidOp(Exceptions.kt:29)
at com.soywiz.korio.compression.deflate.GZIPBase.uncompress$suspendImpl(GZIP.kt:59)
at com.soywiz.korio.compression.deflate.GZIPBase.uncompress(GZIP.kt)
at com.soywiz.korio.compression.CompressionMethodKt.uncompress(CompressionMethod.kt:34)
at com.soywiz.korio.compression.CompressionMethodKt$uncompress$2.invokeSuspend(CompressionMethod.kt:42)
at com.soywiz.korio.compression.CompressionMethodKt$uncompress$2.invoke(CompressionMethod.kt)
at com.soywiz.korio.compression.CompressionMethodKt$uncompress$2.invoke(CompressionMethod.kt)
at com.soywiz.korio.async.RunBlockingNoSuspensionsKt.startCoroutineUndispatched(runBlockingNoSuspensions.kt:52)
at com.soywiz.korio.async.RunBlockingNoSuspensionsKt.runBlockingNoSuspensions(runBlockingNoSuspensions.kt:19)
at com.soywiz.korio.compression.CompressionMethodKt.uncompress(CompressionMethod.kt:41)
at com.soywiz.korio.compression.CompressionMethodKt.uncompress(CompressionMethod.kt:49)
at com.soywiz.korio.compression.CompressionMethodKt.uncompress$default(CompressionMethod.kt:49)
at MainKt.main(Main.kt:9)
Exception in thread "main" com.soywiz.korio.lang.InvalidOperationException: Size doesn't match SIZE(0x00040000 != 0x008A5ECD) || CRC32(0x8A5ECD41 != 0x41000400)
at com.soywiz.korio.lang.ExceptionsKt.invalidOp(Exceptions.kt:29)
at com.soywiz.korio.compression.deflate.GZIPBase.uncompress$suspendImpl(GZIP.kt:59)
at com.soywiz.korio.compression.deflate.GZIPBase.uncompress(GZIP.kt)
at com.soywiz.korio.compression.CompressionMethodKt.uncompress(CompressionMethod.kt:34)
at com.soywiz.korio.compression.CompressionMethodKt$uncompress$2.invokeSuspend(CompressionMethod.kt:42)
at com.soywiz.korio.compression.CompressionMethodKt$uncompress$2.invoke(CompressionMethod.kt)
at com.soywiz.korio.compression.CompressionMethodKt$uncompress$2.invoke(CompressionMethod.kt)
at com.soywiz.korio.async.RunBlockingNoSuspensionsKt.startCoroutineUndispatched(runBlockingNoSuspensions.kt:52)
at com.soywiz.korio.async.RunBlockingNoSuspensionsKt.runBlockingNoSuspensions(runBlockingNoSuspensions.kt:19)
at com.soywiz.korio.compression.CompressionMethodKt.uncompress(CompressionMethod.kt:41)
at com.soywiz.korio.compression.CompressionMethodKt.uncompress(CompressionMethod.kt:49)
at com.soywiz.korio.compression.CompressionMethodKt.uncompress$default(CompressionMethod.kt:49)
at MainKt.main(Main.kt:9)
The file tests as valid with gzip on the commandline and after decompressing with gzip the database is indeed perfectly fine.
This is a minimal reproducible example and I also attached the file in question:
import com.soywiz.korio.compression.deflate.GZIP
import com.soywiz.korio.compression.uncompress
import java.io.File
fun main(args: Array<String>) {
println("Hello World!")
val compressedDBByteArray = File("test.db.gz").inputStream().readBytes()
val uncompressedDBByteArray = compressedDBByteArray.uncompress(GZIP)
}