Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Retain underlying reader if it's an io.Seeker #327

Merged
merged 9 commits into from
Mar 21, 2022
Merged

Retain underlying reader if it's an io.Seeker #327

merged 9 commits into from
Mar 21, 2022

Conversation

jhwz
Copy link
Contributor

@jhwz jhwz commented Mar 21, 2022

See the new test case in formats_test.go.

Because we return an io.MultiReader, we lose a lot of the methods on the interface. This means that when we identify a ZIP file, it cannot then be read with the returned reader.

All this PR does is check if the underlying reader implements io.Seeker, and if so return that instead.

Copy link
Owner

@mholt mholt left a comment

Choose a reason for hiding this comment

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

Ah, that's a good point. Thanks for testing this. How about this one bit of feedback?

formats.go Outdated Show resolved Hide resolved
Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
Copy link
Owner

@mholt mholt left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for another great contribution and for the test case, too!

@mholt mholt merged commit d3e979a into mholt:master Mar 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants