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

Handle 0byte .pars gracefully #17

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

theturboturnip
Copy link

@theturboturnip theturboturnip commented Jan 7, 2024

As discovered in #16 ParTool throws EndOfStreamException when opening 0b pars. Because these pars appear in the wild, I thought it would be best to handle them gracefully.

This changes the behaviour of four commands.
Add throws an error if it's the top-level par, because then it can't infer whether to IncludeDots.
Add tolerates zero-length pars inside the top-level par, treating them as a par with no files inside.
Extract and List warn the user if the top-level par is zero-length, but otherwise treat them as a par with no files inside.
This includes creating empty directories when recursively extracting zero-length PARs inside the top-level par.
Remove tolerates zero-length pars anywhere.

I haven't added command-line flags to change this behaviour, because any error that gets thrown inside Add, Extract, List, or Remove on encountering a 0B .par won't have enough information to help the user.
I don't think the ParArchiveReader can throw an error including the filepath the BinarySource came from, so any error would just indicate "somewhere inside this .par there's an 0b file" and that's not useful.

Includes unit tests for ParArchiveReader in various 0b scenarios.

This adds an AllowZeroLengthPars parameter to ParArchiveReaderParameters, which all usages override to true. I'm open to removing the parameter and making the only behaviour to allow them, if requested.

.Add throws an error if it's the top-level par, because then it can't infer whether to IncludeDots.
.Add tolerates zero-length pars inside the top-level par.
.Extract and .List warn the user if the top-level par is zero-length, but otherwise permit it.
This includes creating empty directories when extracting zero-length PARs recursively.

I haven't added command-line flags to change this behaviour, because any error that gets thrown inside Add, Extract, or List on encountering a 0B .par won't have enough information to help the user.
I don't think the ParArchiveReader can throw an error including the filepath the BinarySource came from, so any error would just indicate "somewhere inside this .par there's an 0b file" and that's not useful.
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.

1 participant