Skip to content

Commit

Permalink
Issue #3419: Do not recursively resolve DAG just to obtain a CID
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Hector Sanjuan <[email protected]>
  • Loading branch information
hsanjuan committed Nov 24, 2016
1 parent ccb46fa commit ac054f3
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions core/commands/pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ type RefKeyList struct {

func pinLsKeys(args []string, typeStr string, ctx context.Context, n *core.IpfsNode) (map[string]RefKeyObject, error) {

mode, ok := pin.StringToPinMode(typeStr)
if !ok {
return nil, fmt.Errorf("Invalid pin mode '%s'", typeStr)
}

keys := make(map[string]RefKeyObject)

for _, p := range args {
Expand All @@ -277,17 +282,11 @@ func pinLsKeys(args []string, typeStr string, ctx context.Context, n *core.IpfsN
return nil, err
}

dagNode, err := core.Resolve(ctx, n.Namesys, n.Resolver, pth)
c, err := core.ResolveToCid(ctx, n, pth)
if err != nil {
return nil, err
}

mode, ok := pin.StringToPinMode(typeStr)
if !ok {
return nil, fmt.Errorf("Invalid pin mode '%s'", typeStr)
}

c := dagNode.Cid()
pinType, pinned, err := n.Pinning.IsPinnedWithType(c, mode)
if err != nil {
return nil, err
Expand Down

0 comments on commit ac054f3

Please sign in to comment.