Skip to content

Commit

Permalink
Support named pins [ipfs/kubo#4757]
Browse files Browse the repository at this point in the history
  • Loading branch information
Voker57 committed Sep 19, 2020
1 parent b8fd93c commit f4cd5b3
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions simple/reprovide.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ func NewBlockstoreProvider(bstore blocks.Blockstore) KeyChanFunc {
// Pinner interface defines how the simple.Reprovider wants to interact
// with a Pinning service
type Pinner interface {
DirectKeys(ctx context.Context) ([]cid.Cid, error)
RecursiveKeys(ctx context.Context) ([]cid.Cid, error)
PinnedCids(recursive bool) ([]cid.Cid, error)
}

// NewPinnedProvider returns provider supplying pinned keys
Expand Down Expand Up @@ -216,21 +215,21 @@ func pinSet(ctx context.Context, pinning Pinner, dag ipld.DAGService, onlyRoots
defer cancel()
defer close(set.New)

dkeys, err := pinning.DirectKeys(ctx)
directCids, err := pinning.PinnedCids(false)
if err != nil {
logR.Errorf("reprovide direct pins: %s", err)
return
}
for _, key := range dkeys {
set.Visitor(ctx)(key)
}

rkeys, err := pinning.RecursiveKeys(ctx)

recursiveCids, err := pinning.PinnedCids(true)
if err != nil {
logR.Errorf("reprovide indirect pins: %s", err)
return
}
for _, key := range rkeys {

for _, key := range directCids {
set.Visitor(ctx)(key)
}

for _, key := range recursiveCids {
if onlyRoots {
set.Visitor(ctx)(key)
} else {
Expand Down

0 comments on commit f4cd5b3

Please sign in to comment.