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

Commit

Permalink
fix: pass through range parameters for partial file load resumption
Browse files Browse the repository at this point in the history
  • Loading branch information
aschmahmann committed Jul 27, 2023
1 parent b258ffa commit 76befb0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,15 +513,17 @@ func loadTerminalUnixFSElementWithRecursiveDirectories(ctx context.Context, c ci
}

from := int64(0)
var byteRange gateway.DagByteRange
if params.Range != nil {
byteRange = *params.Range
from = params.Range.From
}
_, err = f.Seek(from, io.SeekStart)
if err != nil {
return nil, fmt.Errorf("unable to get reset UnixFS file reader: %w", err)
}

return &backpressuredFile{ctx: ctx, fileCid: c, size: fileSize, f: f, getLsys: getLsys, closed: make(chan error)}, nil
return &backpressuredFile{ctx: ctx, fileCid: c, byteRange: byteRange, size: fileSize, f: f, getLsys: getLsys, closed: make(chan error)}, nil
default:
return nil, fmt.Errorf("unknown UnixFS field type")
}
Expand Down
4 changes: 3 additions & 1 deletion lib/graph_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,15 +565,17 @@ func loadTerminalEntity(ctx context.Context, c cid.Cid, blk blocks.Block, lsys *
}

from := int64(0)
var byteRange gateway.DagByteRange
if params.Range != nil {
from = params.Range.From
byteRange = *params.Range
}
_, err = f.Seek(from, io.SeekStart)
if err != nil {
return nil, fmt.Errorf("unable to get reset UnixFS file reader: %w", err)
}

return &backpressuredFile{ctx: ctx, fileCid: c, size: fileSize, f: f, getLsys: getLsys, closed: make(chan error)}, nil
return &backpressuredFile{ctx: ctx, fileCid: c, byteRange: byteRange, size: fileSize, f: f, getLsys: getLsys, closed: make(chan error)}, nil
default:
return nil, fmt.Errorf("unknown UnixFS field type")
}
Expand Down

0 comments on commit 76befb0

Please sign in to comment.