Skip to content

Commit

Permalink
fix: handle error AND zero-length cases from piece lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Oct 14, 2022
1 parent d87dada commit e051f00
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion retrievalmarket/impl/provider_pieces.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ func (p *Provider) getCommonPiecesFromIdentityCidLinks(payloadCID cid.Cid) ([]ci
// for each link, query the dagstore for pieces that contain it
for i, link := range links {
piecesWithThisCid, err := p.dagStore.GetPiecesContainingBlock(link)
if len(piecesWithThisCid) == 0 {
if err != nil {
return nil, fmt.Errorf("getting pieces for identity CID sub-link %s: %w", link, err)
}
if len(piecesWithThisCid) == 0 {
return nil, fmt.Errorf("no pieces for identity CID sub-link %s", link)
}
if i == 0 {
pieces = append(pieces, piecesWithThisCid...)
} else {
Expand Down

0 comments on commit e051f00

Please sign in to comment.