mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-24 03:47:45 +08:00
pin: verify: parse bad node cids early
This commit was moved from ipfs/go-ipfs-http-client@7032dfc9b0
This commit is contained in:
parent
a23da822de
commit
f005b8dc56
@ -110,23 +110,18 @@ func (r *pinVerifyRes) BadNodes() []iface.BadPinNode {
|
||||
type badNode struct {
|
||||
Cid string
|
||||
JErr string `json:"Err"`
|
||||
|
||||
cid cid.Cid
|
||||
}
|
||||
|
||||
func (n *badNode) Path() iface.ResolvedPath {
|
||||
c, err := cid.Parse(n.Cid)
|
||||
if err != nil {
|
||||
return nil // todo: handle this better
|
||||
}
|
||||
return iface.IpldPath(c)
|
||||
return iface.IpldPath(n.cid)
|
||||
}
|
||||
|
||||
func (n *badNode) Err() error {
|
||||
if n.JErr != "" {
|
||||
return errors.New(n.JErr)
|
||||
}
|
||||
if _, err := cid.Parse(n.Cid); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -150,6 +145,13 @@ func (api *PinAPI) Verify(ctx context.Context) (<-chan iface.PinStatus, error) {
|
||||
return // todo: handle non io.EOF somehow
|
||||
}
|
||||
|
||||
for i, n := range out.JBadNodes {
|
||||
out.JBadNodes[i].cid, err = cid.Decode(n.Cid)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
select {
|
||||
case res <- &out:
|
||||
case <-ctx.Done():
|
||||
|
||||
Loading…
Reference in New Issue
Block a user