Port #405: run is_block_zeroed() on the correct block - #12
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports markfasheh/duperemove#405 by Tobias Klausmann (@klausman).
With
--skip-zeroes,process_blocks()checkedis_block_zeroed()onbuffer->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 toprocess_block()on the next line.Adds an integration test (
test_skip_zeroes.py) that scans a two-block file with block hashing +--skip-zeroesand 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