Skip to content

Commit

Permalink
fix: dag-scope=block also returns root block of last path segment
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Jun 2, 2023
1 parent 26824e0 commit fe573f5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions gateway/blocks_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,17 @@ func walkGatewaySimpleSelector(ctx context.Context, p ipfspath.Path, params CarP
}

// If we just need to resolve the path then we're done
if params.Scope == dagScopeBlock {
return nil
}

// If the scope is the block, now we only need to retrieve the root block of the last element of the path.

lctx := ipld.LinkContext{Ctx: ctx}
pathTerminalCidLink := cidlink.Link{Cid: lastCid}

if params.Scope == dagScopeBlock {
_, err = lsys.LoadRaw(lctx, pathTerminalCidLink)
return err
}

// If we're asking for everything then give it
if params.Scope == dagScopeAll {
lastCidNode, err := lsys.Load(lctx, pathTerminalCidLink, basicnode.Prototype.Any)
Expand Down

0 comments on commit fe573f5

Please sign in to comment.