diff --git a/core/coreapi/pin.go b/core/coreapi/pin.go index 0559ef73cd92..ec2cedb83fd4 100644 --- a/core/coreapi/pin.go +++ b/core/coreapi/pin.go @@ -305,6 +305,7 @@ func (api *PinAPI) pinLsAll(ctx context.Context, typeStr string) <-chan coreifac out <- &pinInfo{err: err} return } + rkeys = append(rkeys, streamedCid.C) } } if typeStr == "direct" || typeStr == "all" { @@ -319,27 +320,6 @@ func (api *PinAPI) pinLsAll(ctx context.Context, typeStr string) <-chan coreifac } } } - if typeStr == "all" { - walkingSet := cid.NewSet() - for _, k := range rkeys { - err = merkledag.Walk( - ctx, merkledag.GetLinksWithDAG(api.dag), k, - walkingSet.Visit, - merkledag.SkipRoot(), merkledag.Concurrent(), - ) - if err != nil { - out <- &pinInfo{err: err} - return - } - } - err = walkingSet.ForEach(func(c cid.Cid) error { - return AddToResultKeys(c, "indirect") - }) - if err != nil { - out <- &pinInfo{err: err} - return - } - } if typeStr == "indirect" { // We need to first visit the direct pins that have priority // without emitting them @@ -360,7 +340,8 @@ func (api *PinAPI) pinLsAll(ctx context.Context, typeStr string) <-chan coreifac emittedSet.Add(streamedCid.C) rkeys = append(rkeys, streamedCid.C) } - + } + if typeStr == "indirect" || typeStr == "all" { walkingSet := cid.NewSet() for _, k := range rkeys { err = merkledag.Walk(