CollapseLauncher / SharpHDiffPatch.Core

A port of original HDiffPatch by housisong, written in C# and .NET Standard 2.0 compatible
MIT License
31 stars 6 forks source link

zlib decompressor error #1

Closed sisong closed 11 months ago

sisong commented 1 year ago

out file have some error data when patch by zlib decompressor.

neon-nyan commented 12 months ago

Hi @sisong, Can you please send your patch and original (old) files for the sample? Also, is this produceable on single or directory patch? Or both?

sisong commented 12 months ago

I run Hi3Helper.SharpHDiffPatch/releases/tag/1.4.0 and test some cases,single file to file, uncompress & bz2 & zstd all successed,all zlib test fail.

neon-nyan commented 11 months ago

Hi @sisong,

Sorry for taking too long for the reply due to some activities need to be done on my primary project and some RL stuffs. Seems like the buffer doesn't get filled properly while reading the data from .NET's own DeflateStream. The fix is to use ReadExactly method for reading the data to ensure that the buffer will always be filled.

I've just pushed some commits to fix this issue and also releasing a new hotfix in the release page. Can you please confirm whether the issue is now fixed?

Anyway, thank you for creating HDiffPatch! Your project really motivates me to learn more about C/C++ 😄

sisong commented 11 months ago

tested the new version of SharpHDiffPatch:
diffFile created by $ hdiffz -m -c-zlib ..., SharpHDiffPatch test passed;
but diffFile created by $ hdiffz -s -c-zlib ..., SharpHDiffPatch test failed!

( the same tests, zstd,bzip2,pbzip2 & nocompressor all passed. )

Your project really motivates me to learn more about C/C++

Your project comes with a libzstd.dll, curious why not choose to compile out and come with a libhpatchz .dll?

neon-nyan commented 11 months ago

Hi @sisong

Sorry for my late response (again). I see. Seems only the zlib-compressed stream diff fails in this case. Will try to investigate it later.

Your project comes with a libzstd.dll, curious why not choose to compile out and come with a libhpatchz .dll?

I used to use the native library in the first place for my other project called Collapse, which is basically a universal launcher for miHoYo's PC Games. I used it to patch all the hdiff patch files for updating the game.

But in the end, the reason why I choose to make this C# port of HPatch instead of using the native library is that, I want to make the project to be fully compatible with .NET codes, give more accessibility for other .NET projects to use HDiff patch and minimizing the dependencies of code interop while also make it easier to diagnose if something goes wrong with the patching process. The second is that I want to make some additional APIs including an API to get the info (mostly header related) of the patch file and the "progress event" so I can track the current patching progress in real-time.

neon-nyan commented 11 months ago

Hi @sisong,

I just pushed another release (v1.4.3) that hopefully fix the issue you reported last time. Can you please check if the issue still persist or not?

sisong commented 11 months ago

all cases tests passed.