Serialize actual size of packed file data instead of the size of the original file to enable compression


When serializing pack files for being packed in the resulting installer, we're writing the size of the original file to the pack stream for being able to get the size of bytes to read back later from the pack stream during installing. This has two inconveniences:

  • There is just written the size of the original file. This size might change when compressing it before serializing, so we can't really compress a packed file using an additional compressor stream.

  • Generally, the size is written to the pack stream itself before the file is serialized to the same stream, so if the serialized size changes after filtering or compression the unpacker doesn't notice this change and we can't change this size later after serializing, thus, the unpacker would receive the wrong number of bytes to deserialize.

Change the above drawbacks in this way:

  • Remove writing the size before serializing and replace this by writing the serialized pack data size after serializing, getting the number of written bytes from the final serializer stream.




René Krell
March 18, 2017, 11:44 PM

I can reproduce this now with your example, thanks. I'll have a look at this.

René Krell
March 18, 2017, 11:50 PM

I believe I have a fix. The code you referred to is the right one.

The wrong line is

and should be:

because PackFile.size() is the compressed size of the file, but PackFile.length() is the uncompressed size, which should apply here while uncompressing it to the target file.

Thanks for the hint.
After a few more tests I will push this to 5.1.0-RC5.

René Krell
March 19, 2017, 9:48 AM

I've sent pull request #592 which fixes the pack compression support.

Роман Кисель
March 20, 2017, 8:28 AM

Good news! Thank you very much!

René Krell
March 20, 2017, 12:50 PM

Check out 5.1.0-RC5 whether it is ok also for you know.



René Krell


René Krell


Functional - non-breaking and safe in existing environments




Fix versions

Affects versions