mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-03 12:16:18 +08:00
core/commands/pin: refactor 'pin ls'
License: MIT Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
This commit is contained in:
@ -212,13 +212,18 @@ Example:
|
||||
}
|
||||
|
||||
keys := make(map[string]RefKeyObject)
|
||||
if typeStr == "direct" || typeStr == "all" {
|
||||
for _, k := range n.Pinning.DirectKeys() {
|
||||
|
||||
AddToResultKeys := func(keyList []key.Key, typeStr string) {
|
||||
for _, k := range keyList {
|
||||
keys[k.B58String()] = RefKeyObject{
|
||||
Type: "direct",
|
||||
Type: typeStr,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if typeStr == "direct" || typeStr == "all" {
|
||||
AddToResultKeys(n.Pinning.DirectKeys(), "direct")
|
||||
}
|
||||
if typeStr == "indirect" || typeStr == "all" {
|
||||
ks := key.NewKeySet()
|
||||
for _, k := range n.Pinning.RecursiveKeys() {
|
||||
@ -232,20 +237,11 @@ Example:
|
||||
res.SetError(err, cmds.ErrNormal)
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
for _, k := range ks.Keys() {
|
||||
keys[k.B58String()] = RefKeyObject{
|
||||
Type: "indirect",
|
||||
}
|
||||
}
|
||||
AddToResultKeys(ks.Keys(), "indirect")
|
||||
}
|
||||
if typeStr == "recursive" || typeStr == "all" {
|
||||
for _, k := range n.Pinning.RecursiveKeys() {
|
||||
keys[k.B58String()] = RefKeyObject{
|
||||
Type: "recursive",
|
||||
}
|
||||
}
|
||||
AddToResultKeys(n.Pinning.RecursiveKeys(), "recursive")
|
||||
}
|
||||
|
||||
res.SetOutput(&RefKeyList{Keys: keys})
|
||||
|
Reference in New Issue
Block a user