Skip to content

.zsync Length: is incorrect if source file is not a multiple of block size causing truncated file to be generated on the destination #85

@dh-apporto

Description

@dh-apporto

Problem

When generating a .zsync file for a large source file that is not an exact multiple of the block size, the .zsync "Length" is truncated and the last partial block is omitted. As a result, zsync2 clients download an incomplete file.

Steps to Reproduce

  1. Create a large file whose size is not a multiple of the block size (e.g., 3.9 GB, block size 524288).
  2. Run zsyncmake2 to create the .zsync file.
  3. Download using zsync2. Resulting file is truncated.

Example of file sizes differing where the source test-release.tgz zsync file was created with blocksize of 524288, zsync2 was used to download the file and output as appliance-release.tgz. cmp was used to verify that only the last partial block was missing from the downloaded file.

# ls -l appliance-release.tgz test-release.tgz 
-rw------- 1 root root 3934257152 Aug  6 23:01 appliance-release.tgz
-rw-r--r-- 1 root root 3934466485 Aug  6 23:01 test-release.tgz

Workaround

Padding the file to a block-aligned size avoids the issue.

Fix

I have created a PR to address this issue.

(see PR #84 )

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