fix: auto-rewind source reader on seekable entry points#162
Merged
Conversation
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
Coverage Report for CI Build 24835701463Coverage increased (+0.1%) to 77.755%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions2 previously-covered lines in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
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.
Summary
run_with_archive(sync path) andArchiveIterator::new(iterator path), so callers can reuse the sameRead + Seekreader across successivelist_archive_files/uncompress_archive_file/ArchiveIteratorcalls without a manual rewind.seek(SeekFrom::Start(0))between calls surfaced as an opaque "unrecognized format" error, because libarchive only sniffs the format from byte 0.Closes #117.
Test plan
cargo test(39 integration + 14 doc tests pass)reader_is_rewound_between_callstest exercises the list → extract → list → iterate sequence on one reader