Extension hinting for ReaderFactory for better first try factory success #945
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.
Also used by TarFactory to hint what compressiontype to attempt first
Close #942
This adds extension hinting support to ReaderFactory and allows compressors to optionally use the hinting as well for their own prioritization.
This only prioritizes which factories/methods we try first so should not result in a change of functionality for anyone (it also only does the prioritization if you provide the extension as a hint).
I added prioritization to tar as well, this required rewriting it a bit but it allowed removing a good bit of duplicate code. I don't know why certain tar methods require wrapping the rewind stream again, would seem this maybe should be a property on the type, but I did preserve this functionality.
I added gzip to TarFactory as well. While the GzipFactory would eventually handle it from brute force it seemed like it belonged in TarFactory with the others.
For bare tar archives I no longer use TarReader.Open as it has redundant code once again brute forcing the compression types. Given the code path was only triggered if the IsTarFile check passed before even if they were slightly different it shouldn't matter.
I don't think this introduces much of a different code path that could be exploited but the tar change would probably be the biggest.
This makes it a bit easier to track 'legitimate' exceptions in the library when debugging vs ones caused during the type brute forcing.