@cryptotaxi247 / kubo / commits / ac054f3d8

Issue #3419: Do not recursively resolve DAG just to obtain a CID

License: MIT Signed-off-by: Hector Sanjuan <code@hector.link>

Hector Sanjuan committed Nov 24, 2016 at 17:07 UTC ac054f3d8f64265654a5d5778ecdd483773ab0ee
1 file changed +6 -7
core/commands/pin.go
+6 -7
@@ -269,6 +269,11 @@ type RefKeyList struct {
269
270 func pinLsKeys(args []string, typeStr string, ctx context.Context, n *core.IpfsNode) (map[string]RefKeyObject, error) {
271
272 + mode, ok := pin.StringToPinMode(typeStr)
273 + if !ok {
274 + return nil, fmt.Errorf("Invalid pin mode '%s'", typeStr)
275 + }
276 +
277 keys := make(map[string]RefKeyObject)
278
279 for _, p := range args {
@@ -277,17 +282,11 @@ func pinLsKeys(args []string, typeStr string, ctx context.Context, n *core.IpfsN
282 return nil, err
283 }
284
280 - dagNode, err := core.Resolve(ctx, n.Namesys, n.Resolver, pth)
285 + c, err := core.ResolveToCid(ctx, n, pth)
286 if err != nil {
287 return nil, err
288 }
289
285 - mode, ok := pin.StringToPinMode(typeStr)
286 - if !ok {
287 - return nil, fmt.Errorf("Invalid pin mode '%s'", typeStr)
288 - }
289 -
290 - c := dagNode.Cid()
290 pinType, pinned, err := n.Pinning.IsPinnedWithType(c, mode)
291 if err != nil {
292 return nil, err