Skip to content

fix: auto-rewind source reader on seekable entry points#162

Merged
otavio merged 1 commit into
masterfrom
fix/auto-rewind-seekable-readers
Apr 23, 2026
Merged

fix: auto-rewind source reader on seekable entry points#162
otavio merged 1 commit into
masterfrom
fix/auto-rewind-seekable-readers

Conversation

@otavio

@otavio otavio commented Apr 23, 2026

Copy link
Copy Markdown
Member

Summary

  • Seek the source reader to offset 0 at the top of run_with_archive (sync path) and ArchiveIterator::new (iterator path), so callers can reuse the same Read + Seek reader across successive list_archive_files / uncompress_archive_file / ArchiveIterator calls without a manual rewind.
  • Previously, forgetting the manual seek(SeekFrom::Start(0)) between calls surfaced as an opaque "unrecognized format" error, because libarchive only sniffs the format from byte 0.
  • Changelog entry + regression test covering list → extract → list → iterate on a single file handle.

Closes #117.

Test plan

  • cargo test (39 integration + 14 doc tests pass)
  • New reader_is_rewound_between_calls test exercises the list → extract → list → iterate sequence on one reader

Callers previously had to manually `seek(SeekFrom::Start(0))` between
successive uses of the same reader (e.g. list_archive_files followed by
uncompress_archive_file), because libarchive only recognizes the archive
format from byte 0. Forgetting the rewind surfaced as an opaque
"unrecognized format" error.

Since the public entry points already require `Read + Seek`, rewind the
reader at the top of `run_with_archive` and `ArchiveIterator::new` so
reader reuse works out of the box.

Closes #117
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 24835701463

Coverage increased (+0.1%) to 77.755%

Details

  • Coverage increased (+0.1%) from the base build.
  • Patch coverage: 23 of 23 lines across 3 files are fully covered (100%).
  • 2 coverage regressions across 1 file.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

2 previously-covered lines in 1 file lost coverage.

File Lines Losing Coverage Coverage
src/async_support.rs 2 69.72%

Coverage Stats

Coverage Status
Relevant Lines: 2477
Covered Lines: 1926
Line Coverage: 77.76%
Coverage Strength: 89.08 hits per line

💛 - Coveralls

@otavio
otavio merged commit 0139bff into master Apr 23, 2026
14 checks passed
@otavio
otavio deleted the fix/auto-rewind-seekable-readers branch April 23, 2026 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Clearer errors/warnings when using list_archive_files followed by uncompress_archive_file

2 participants