Skip to content

Commit

Permalink
fix: gateway panic because of overshadowed err
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Nov 10, 2023
1 parent f1442f7 commit f9fd4a5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions gateway/blocks_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ func (bb *BlocksBackend) Head(ctx context.Context, path path.ImmutablePath) (Con
var emptyRoot = []cid.Cid{cid.MustParse("bafkqaaa")}

func (bb *BlocksBackend) GetCAR(ctx context.Context, p path.ImmutablePath, params CarParams) (ContentPathMetadata, io.ReadCloser, error) {
pathMetadata, err := bb.ResolvePath(ctx, p)
if err != nil {
pathMetadata, resolveErr := bb.ResolvePath(ctx, p)
if resolveErr != nil {
rootCid, err := cid.Decode(strings.Split(p.String(), "/")[2])
if err != nil {
return ContentPathMetadata{}, nil, err
Expand Down Expand Up @@ -327,8 +327,11 @@ func (bb *BlocksBackend) GetCAR(ctx context.Context, p path.ImmutablePath, param
LastSegment: path.FromCid(rootCid),
ContentType: "",
}, io.NopCloser(&buf), nil
} else if err != nil {
return ContentPathMetadata{}, nil, err
} else {
return ContentPathMetadata{}, nil, resolveErr
}
return ContentPathMetadata{}, nil, err
}

if p.Namespace() != path.IPFSNamespace {
Expand Down

0 comments on commit f9fd4a5

Please sign in to comment.