ipld / ipld/go-car

NewReadOnly fails on exhausted ReadSeeker

Open
#336 4 comments 0 reactions 0 assignees View on GitHub
P2
Dominant language
Go
Stars
175
Forks
54
Avg merge
6d 5h
Merged PRs (30d)
4

Description

- An os.File has GenerateIndex() called on
- This puts the os.File's underlying Reader at EOF
- If one then calls NewReadOnly [the check here](https://github.com/ipld/go-car/blob/v2.5.0/v2/blockstore/readonly.go#L155-L156) falls through to the io.Reader, sees the EOF and aborts

Observe the workaround at lines 81~83 in [the sequence here](https://github.com/ribasushi/fil-fip36-vote-tally/blob/cad0b4225/parsestate/util.go#L73-L91). A potential fix is to rewind when the argument is a ReadSeeker, before dropping to the Reader part.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.