vcdiff-java icon indicating copy to clipboard operation
vcdiff-java copied to clipboard

Could you please consider to update your java library to handle secondary compression of delta file sections

Open RudyBisiaux opened this issue 9 years ago • 20 comments

All is in the title. I have a project with a file and a patch given by a server. When i try do decode with this library on my Android application i have this error: "java.io.IOException: Secondary compression of delta file sections is not supported"

i specify that the server don't use this java library to generate the file but still use a VCDiff library.

Thanks for your answers.

RudyBisiaux avatar May 29 '17 14:05 RudyBisiaux

The original RFC didn't specify any secondary compression schemes. If there's a followup, could you link me to it?

It could be a proprietary compressor that the code generating it uses. Do you know what server you're using? Adding support for user-registered secondary compression is an option.

It's also possible that you found a bug or the diff is corrupt. If there isn't anything sensitive in it, could you send me the dictionary and the delta?

ehrmann avatar May 29 '17 17:05 ehrmann

That error shouldn't happen. You should have seen "Secondary compression is not supported" before it was able to get that far. I'm really curious to see the delta file.

ehrmann avatar May 29 '17 22:05 ehrmann

Hi, thanks for reply

I use the xdelta to generate patch on server part (i own it) : https://github.com/jmacd/xdelta As you can see on command-line there is on option to disabled secondary compression -S [djw|fgk] enable/disable secondary compression but don't change the behavior of the library

i use your library in my android application to apply patch on the original file.

thanks again.

RudyBisiaux avatar May 30 '17 07:05 RudyBisiaux

I'm looking into it. Does it work fine if you disable secondary compression?

ehrmann avatar May 31 '17 05:05 ehrmann

Hi, If i don't use secondary compression i have the same error this is why i'm pretty confused with this ^^.

Thanks again.

RudyBisiaux avatar May 31 '17 06:05 RudyBisiaux

Couple of things: xdelta3 is pretty non-standard by default. You need to add -S to disable secondary compression (it defaults to lzma), and -A to disable adding an "app header."

After adding those, vcdiff-java and Google's open-vcdiff both failed to decode the patch. The error was something like

The length of the delta encoding does not match the size of the header plus the sizes of the data sections

In the short-term, I have a test case I can add (that will fail) with an xdelta3 diff, and an improvement to an exception message. Longer term, I'll try to poke around the simple diff to figure out if open-vcdiff or xdelta3 is wrong.

ehrmann avatar Jun 01 '17 06:06 ehrmann

Ok, Thanks a lot for you informations and actions.

Sincerely.

RudyBisiaux avatar Jun 01 '17 07:06 RudyBisiaux

Try using -S -A -n when using xdelta3. Without -n, an adler32 chcecksum is added to the window section, but this seems to be non-standard.

ehrmann avatar Jun 03 '17 16:06 ehrmann

If I have time to add in xdelta3 extensions, which would you rather have: adler32 checksums or lzma secondary compression?

ehrmann avatar Jun 04 '17 04:06 ehrmann

Hi, When i use the -S -A -n options i have a exception like : Source segment length (91) is larger than target file (0) my dictionary length is 2287616 and my encoding length is 312551 (if it can help).

i think Izma secondary compression is more valuable to have

Thanks again !

RudyBisiaux avatar Jun 05 '17 07:06 RudyBisiaux

Can you send me the dictionary and the delta?

ehrmann avatar Jun 05 '17 15:06 ehrmann

One other thing to try: in the Java code, make sure you didn't disable target matches, e.g.

VCDiffDecoderBuilder.builder()
                .withAllowTargetMatches(false)
                .buildStreaming();

allowTargetMatches should probably be set to true (the default) if you're seeing that error. Or try setting it to false for fun.

Also make sure your expected file is <64M. If it's larger, you might need to increase the maximum target file and window sizes.

The reason for fine-grained control like this is corrupt deltas can decode to some pretty large output, and capping memory usage (target matches, target window size) and target size can prevent this.

ehrmann avatar Jun 06 '17 05:06 ehrmann

Hi, I unfortunately can't give you the dictionary and the delta for now, the data inside are sensitive, but i will looking to give you something, without certainty.

I try to play with the withAllowTargetMatches(true) or false i still have the same error with true option : Source segment length (91) is larger than target file (0) and have this error with false option Delta file contains VCD_TARGET flag, which is not allowed by current decoder settings

Thanks a lot to be concerned

RudyBisiaux avatar Jun 06 '17 07:06 RudyBisiaux

What about just the delta? There's definitely stuff in it, but if the dictionary is 10x bigger, it's a lot harder to reconstruct in a meaningful way. If you've encoded text, you can see the text just by looking at the delta file.

ehrmann avatar Jun 06 '17 15:06 ehrmann

Ok, i have the permission to give those file. Hope it will help you.

[redacted]

thanks again

RudyBisiaux avatar Jun 06 '17 15:06 RudyBisiaux

Got it. I'll late a look later today.

ehrmann avatar Jun 06 '17 15:06 ehrmann

open-vcdiff produced this error, too (I get the same error when I swap dictionaries):

$ vcdiff decode -dictionary product_20170518 -delta testpatch -target out
ERROR: Source segment length (91) is larger than target file (0)
Error trying to decode data chunk of length 983489

Since vcdiff-java is based on open-vcdiff, this could be a common bug, or it could be an xdelta3 bug. I'll continue investigating.

ehrmann avatar Jun 07 '17 14:06 ehrmann

The delta you sent me has an xdelta3 app header. When I hit this before, adding -A fixed the problem. If you do head -c 6 testpatch | hexdump -C, you get

00000000  d6 c3 c4 00 04 06                                 |......|

the 04 is the vcdiff Hdr_Indicator. xdelta3 defines them here.

Once I saw that, I tried using xdelta3 3.0.10 to create a diff:

xdelta3 -e -S -n -A -s product_20170518 product_20170529 testpatch

I didn't have any problems applying the patch to product_20170518, and the output matched product_20170529.

ehrmann avatar Jun 08 '17 05:06 ehrmann

Were you able to get your diff to work by adding -A to the xdelta3 command?

ehrmann avatar Jun 22 '17 15:06 ehrmann

Hi, Sorry for the wait. This work perfectly ! Thank you a lot for your assistance.

Best regards

RudyBisiaux avatar Jul 13 '17 12:07 RudyBisiaux