Skip to content
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

Applying a decode twice nukes the target file #86

Open
BullyWiiPlaza opened this issue Apr 5, 2020 · 0 comments
Open

Applying a decode twice nukes the target file #86

BullyWiiPlaza opened this issue Apr 5, 2020 · 0 comments

Comments

@BullyWiiPlaza
Copy link

BullyWiiPlaza commented Apr 5, 2020

I noticed that when I apply the same decode command twice, it will firstly decode correctly and the second time generate an error and overwrites the target file with an empty file.

My suggestion would be to avoid writing an empty file if an error occurs or to detect that the diff has already been applied and simply do nothing. Currently, it is dangerous to accidentally apply a decode twice but I'm not sure if this is intended behavior or a bug.

How to reproduce

Give the two files modified and original.

Encode step:

vcdiff encode -dictionary modified -target original -delta patch
vcdiff encode -dictionary original -target modified -delta undo

Now we have a patch and an undo file for applying the patch and undo'ing it.

Decode step:

vcdiff decode -dictionary modified -target original_decoded -delta patch
vcdiff decode -dictionary original_decoded -target modified_decoded -delta undo

Verification step:

fc original original_decoded
Comparing files original and ORIGINAL_DECODED
FC: no differences encountered

fc modified modified_decoded
Comparing files modified and MODIFIED_DECODED
FC: no differences encountered

All good.

The "bug" (?):

vcdiff decode -dictionary modified_decoded -target modified_decoded -delta patch

vcdiff decode -dictionary modified_decoded -target modified_decoded -delta patch
ERROR: Source segment length (528920) is larger than dictionary (51502)
Error trying to decode data chunk of length 50912

Now modified_decoded has 0 KB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant