Skip to content
This repository was archived by the owner on Apr 18, 2026. It is now read-only.
This repository was archived by the owner on Apr 18, 2026. It is now read-only.

Applying a decode twice nukes the target file #86

@BullyWiiPlaza

Description

@BullyWiiPlaza

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions