Skip to content

feat: add per-record CRC skip in iter_records#1

Open
jgwesterlund wants to merge 10 commits intomainfrom
feat/crc-skip
Open

feat: add per-record CRC skip in iter_records#1
jgwesterlund wants to merge 10 commits intomainfrom
feat/crc-skip

Conversation

@jgwesterlund
Copy link
Owner

Pull Request

What does this change do?

Adds a skip_corrupt parameter to iter_records() that scans forward past corrupt records instead of stopping at the first one. Tracks the number of skipped corrupt regions in _last_iter_skipped.

Why is this needed?

Previously, iteration stopped at the first corrupt record, making it impossible to recover valid records beyond corruption. This enables data recovery from partially corrupted rings. The scan searches up to full ring capacity—no fixed 4096-byte cap—so corruption spanning arbitrary lengths is handled.

Type of change

  • Feature

How was this tested?

5 new tests in tests/test_extended.py:

  • Skip single corrupt record in middle, verify records before/after are yielded
  • Skip multiple corrupt regions
  • skip_corrupt=False (default) still stops at first corruption
  • _last_iter_skipped count is accurate
  • Corruption spanning large regions (>4096 bytes) is handled

All 41 tests pass, ruff clean, mypy clean.

Checklist

  • I tested this locally
  • I didn't reformat the entire repo
  • I wrote sane commit messages
  • I read the contributing guide
  • This probably won't summon new bugs

Notes for reviewers

Records start at DATA_START=4, which is offset 4 mod 8. The scan increments by ALIGN (8 bytes) from the current offset rather than using _align_up() to global 8-byte boundaries, since that would skip valid record offsets.

Docs updated: usage.md, api.md, recovery.md.

jgwesterlund and others added 10 commits March 4, 2026 12:55
Merge pull request #1 from jgwesterlund/fix/ring-open-recovery-safety
Automatically generated by python-semantic-release
Automatically generated by python-semantic-release
lets hope, cause im tired....
Add skip_corrupt parameter to iter_records() that scans forward past
corrupt records instead of stopping at the first one. Track skipped
count in _last_iter_skipped. Scan searches up to full ring capacity
to handle corruption spanning arbitrary lengths.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

2 participants