Skip to content

Port #405: run is_block_zeroed() on the correct block - #12

Merged
martinus merged 1 commit into
masterfrom
upstream/405-skip-zeroes-block
Jul 15, 2026
Merged

Port #405: run is_block_zeroed() on the correct block#12
martinus merged 1 commit into
masterfrom
upstream/405-skip-zeroes-block

Conversation

@martinus

Copy link
Copy Markdown
Owner

Ports markfasheh/duperemove#405 by Tobias Klausmann (@klausman).

With --skip-zeroes, process_blocks() checked is_block_zeroed() on buffer->buf + buffer->dl_offset (always block 0) instead of block #i, so it skipped either every block or none depending only on whether the first block was zero. The fix checks the block actually being hashed — the same offset already passed to process_block() on the next line.

Adds an integration test (test_skip_zeroes.py) that scans a two-block file with block hashing + --skip-zeroes and asserts which block survives, catching the bug in both directions. Full suite green (39 tests).

Reviewed via /simplify: dropped a redundant all-zero case (couldn't distinguish bug from fix) and strengthened the assertions to check block offsets, not just counts.

🤖 Generated with Claude Code

Ports markfasheh#405 by Tobias Klausmann.

With --skip-zeroes, process_blocks() ran is_block_zeroed() on
buffer->buf + buffer->dl_offset - always block 0 - instead of block #i,
so it skipped either every block or none depending only on whether the
first block happened to be zero. Check the block actually being hashed
(matching the offset already passed to process_block() just below).

Adds an integration test that scans a two-block file with block hashing
and --skip-zeroes and asserts which block survives, catching the bug in
both directions (leading and trailing zero block).

Co-authored-by: Tobias Klausmann <klausman@schwarzvogel.de>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@martinus
martinus merged commit 8484ea4 into master Jul 15, 2026
2 checks passed
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

Successfully merging this pull request may close these issues.

1 participant