Request correct read size with startOffset in pieceProvider

This commit is contained in:
Łukasz Magiera 2021-11-27 00:05:45 +01:00
parent 9110e6f632
commit 05aa860459
2 changed files with 2 additions and 2 deletions

View File

@ -82,7 +82,7 @@ func (p *pieceProvider) tryReadUnsealedPiece(ctx context.Context, sector storage
// Reader returns a reader for an unsealed piece at the given offset in the given sector. // Reader returns a reader for an unsealed piece at the given offset in the given sector.
// The returned reader will be nil if none of the workers has an unsealed sector file containing // The returned reader will be nil if none of the workers has an unsealed sector file containing
// the unsealed piece. // the unsealed piece.
r, err := p.storage.Reader(ctx, sector, abi.PaddedPieceSize(pieceOffset.Padded()+startOffset.Padded()), size.Padded()) r, err := p.storage.Reader(ctx, sector, abi.PaddedPieceSize(pieceOffset.Padded()+startOffset.Padded()), size.Padded()-abi.PaddedPieceSize(startOffset.Padded()))
if err != nil { if err != nil {
log.Debugf("did not get storage reader;sector=%+v, err:%s", sector.ID, err) log.Debugf("did not get storage reader;sector=%+v, err:%s", sector.ID, err)
cancel() cancel()

View File

@ -110,7 +110,7 @@ func (p *pieceReader) ReadAt(b []byte, off int64) (n int, err error) {
p.r = nil p.r = nil
} }
log.Debugw("pieceReader new stream", "at", p.rAt, "off", off-p.rAt) log.Debugw("pieceReader new stream", "piece", p.pieceCid, "at", p.rAt, "off", off-p.rAt)
p.rAt = off p.rAt = off
p.r, _, err = p.api.FetchUnsealedPiece(p.ctx, p.pieceCid, uint64(p.rAt)) p.r, _, err = p.api.FetchUnsealedPiece(p.ctx, p.pieceCid, uint64(p.rAt))