1024jp / GzipSwift

Swift package that enables gzip/gunzip Data using zlib
MIT License
544 stars 134 forks source link

GzipError.Kind.buffer thrown on gunzipped() #51

Open inigonavenio opened 2 years ago

inigonavenio commented 2 years ago

I have encountered an issue while gunzipping a file 52KB size long. I mention size as I reckon that is the root cause. public var isGzipped: Bool works correctly, and recognises the file as such, a gzipped file. However, library fails to gunzip it and throws and error when using public func gunzipped() throws -> Data

Error thrown looks as follows: ▿ GzipError

Reading through zlib documentation, seems like Z_BUF_ERROR is not fatal (this is what causes GzipSwift to eventually throw Gzip.GzipError.Kind.buffer), and deflate() can be called again with more input and more output space to continue compressing.

I'm attaching the above mentioned file, in hopes that this issue gets resolved by contributors soon / at some point :)

UPONAN_gzip.txt

shahamitj commented 2 months ago

I received the same error on my device. Turns out that the gzip'ed data was not complete. Make sure that you are flushing / closing the stream when generating the gzip data. The error message that I received was not clear.