Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite using winnow and fixed parse_tar #1

Merged
merged 1 commit into from
Feb 11, 2024

Conversation

NobodyXu
Copy link
Member

parse_tar now break the iteration once it encounters None from parse_entry instead of using Iterator::flatten, which keeps going instead of breaking the loop.

It also fixed parse_entry_streaming to treat eof as end of the archive file as per the spec.

Why rewrite using winnow?

Related blog post:

@NobodyXu
Copy link
Member Author

Original PR: Berrysoft#2

`parse_tar` now break the iteration once it encounters `None` from
`parse_entry` instead of using `Iterator::flatten`, which keeps going
instead of breaking the loop.

It also fixed `parse_entry_streaming` to treat eof as end of the archive
file as per the spec.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
@passcod
Copy link
Member

passcod commented Jan 21, 2024

Looks good at first glance, will look more in depth later this week

@NobodyXu
Copy link
Member Author

cc @passcod in case you forgot this PR

@passcod
Copy link
Member

passcod commented Jan 31, 2024

Yeah I've been flat out at work, didn't even really have a weekend. I'll do it over waitangi (coming weekend)

Copy link
Member

@passcod passcod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I took so long. This all looks good, so i'm happy to stamp

@@ -4,30 +4,31 @@
//! ```no_run
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let file = std::fs::read("foo.tar")?;
//! # fn parse(file: &[u8]) -> Result<(), Box<dyn std::error::Error + '_>> {
//! let (_, entries) = tar_parser2::parse_tar(&file[..])?;
//! let entries = tar_parser2::parse_tar(&mut &file[..]).map_err(|err| err.into_inner().unwrap())?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given this is a fairly significant rewrite that we're not upstreaming, maybe we should rename to tar_parser3? or to binstall-tar-parser?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think tar-parser3 is a good name, having binstall- prefix makes it looks like a project only binstall can use.

@NobodyXu NobodyXu added this pull request to the merge queue Feb 11, 2024
@NobodyXu
Copy link
Member Author

Thank you for taking your time to review!

Merged via the queue into cargo-bins:main with commit 78285f4 Feb 11, 2024
4 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.

2 participants