-
-
Notifications
You must be signed in to change notification settings - Fork 791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pako 1.x -> 2.x raw decompression regression with intermediate flush(?) #235
Comments
See #234 (comment) v2 changed wrapper to "standard one", according to zlib docs. v1 terminated process on sync mark, that caused problem with multistream files. v2 does NOT emit end on sync mark, but still should flush data (and you can join it manually anytime). In short - code, working in v1 used buggy behaviour :). Wrapper is not magical, and can not fit all possible use cases. If you need partial compress/decompress - see wrapper src and tweak for your need. Also, if you know popular multistream use cases - you can suggest tests, to be sure this will not be broken in future. |
Thank you for quick reply. I am not sure which code specifically is the wrapper (I am not familiar with the internal architecture) and the noted comment seems to reference deflation rather than inflation but I tried the following (extending the code above): const inflator2 = new pako2.Inflate({raw: true});
inflator2.push(partialCompressed, true);
console.log("inflator2", inflator2); I do see the inflated content is still in Also not sure what multistream means specifically in this context; my use case is I've got a compressed stream containing a stack of images (written natively with zlib). Each image is flushed explicitly (locations in the output stream are remembered / stored) with Z_FULL_FLUSH to allow extracting specific single images from the stack without extracting the entire stack. |
https://github.com/nodeca/pako/tree/master/lib - those 2 files are top level wrappers for zlib port. If you wish to use partial compress-decompress - you should understand what happens there, and be able to patch/replace for your needs.
See wrapper sources first. In theory, Z_xxx_FLUSH should force pending output to Also, you can create your own custom wrapper for your needs, and use zlib directly.
It means deflated data, consisting of several parts => having "sync mark" inside. |
Thank you for elaborating. The current condition for the Line 262 in 0398fad
So there currently is no output chunk (even when flushing) unless the output area is completely full or the input stream was fully consumed. Would you consider changing this to also consume the data (call Being able to manually trigger / force finalization ( I suppose I could write my own wrapper (the zlib interface itself isn't exported though(?)) or manually concatenate the data from both |
I have no objection about improving flush in inflate wrapper, but i don't know how to do it right. Previous attempt to add "everything possible" (in v1) ended with cryptic & unmanainable wrapper without tests. So i had to drop all reinvented weels and do everything from scratch. If anyone has time, i'd suggest to investigate logic of nodejs native zlib wrapper. It's battle-tested and should be ok. Or, you can just copy-paste inflate wrapper from v1. If you have only one use case, you don't need to worry about universal solution. |
Given the following package.json:
And following index.mjs:
Running
node index.mjs
the output I get is:inflateRaw
returns the expected output in version 1 but returns nothing (undefined
) in version 2.I might have missed an explicit / intended behavior change that explains this and maybe there is some specific option that would also make this work with version 2 otherwise this looks like a regression?
The text was updated successfully, but these errors were encountered: