Skip to content

Commit

Permalink
unixfs/feather: cleanup CID normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorropo committed Nov 18, 2023
1 parent c3929ff commit b568a58
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions unixfs/feather/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,13 @@ func NewClient(opts ...Option) (*Client, error) {
// DownloadFile takes in a [cid.Cid] and return an [io.ReadCloser] which streams the deserialized file.
// You MUST always call the Close method when you are done using it else it would leak resources.
func (client *Client) DownloadFile(c cid.Cid) (io.ReadCloser, error) {
c = normalizeCidv0(c)

attempts := client.retries
if attempts != math.MaxUint {
attempts++
}
d := &downloader{
client: client,
state: []region{{c: c}},
state: []region{{c: normalizeCidv0(c)}},
buf: *bufio.NewReaderSize(nil, maxElementSize*2),
remainingAttempts: attempts,
}
Expand Down Expand Up @@ -202,7 +200,6 @@ func (d *downloader) Read(b []byte) (_ int, err error) {

var data []byte
c := todo.c
c = normalizeCidv0(c)

pref := c.Prefix()
switch pref.MhType {
Expand Down Expand Up @@ -235,7 +232,7 @@ func (d *downloader) Read(b []byte) (_ int, err error) {
for i := len(childs); i > 0; {
i--
regions = append(regions, region{
c: childs[i].Cid,
c: normalizeCidv0(childs[i].Cid),
size: childs[i].FileSize,
rangeKnown: true,
})
Expand Down

0 comments on commit b568a58

Please sign in to comment.