mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-26 23:53:19 +08:00
fix ipfs pin verify --verbose
not working
Resolves https://github.com/ipfs/go-ipfs/issues/4761 License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
This commit is contained in:
@ -462,25 +462,23 @@ var verifyPinCmd = &cmds.Command{
|
||||
cmds.Text: func(res cmds.Response) (io.Reader, error) {
|
||||
quiet, _, _ := res.Request().Option("quiet").Bool()
|
||||
|
||||
outChan, ok := res.Output().(<-chan interface{})
|
||||
out, err := unwrapOutput(res.Output())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r, ok := out.(*PinVerifyRes)
|
||||
if !ok {
|
||||
return nil, u.ErrCast()
|
||||
return nil, e.TypeErr(r, out)
|
||||
}
|
||||
|
||||
rdr, wtr := io.Pipe()
|
||||
go func() {
|
||||
defer wtr.Close()
|
||||
for r0 := range outChan {
|
||||
r := r0.(*PinVerifyRes)
|
||||
if quiet && !r.Ok {
|
||||
fmt.Fprintf(wtr, "%s\n", r.Cid)
|
||||
} else if !quiet {
|
||||
r.Format(wtr)
|
||||
}
|
||||
}
|
||||
}()
|
||||
buf := &bytes.Buffer{}
|
||||
if quiet && !r.Ok {
|
||||
fmt.Fprintf(buf, "%s\n", r.Cid)
|
||||
} else if !quiet {
|
||||
r.Format(buf)
|
||||
}
|
||||
|
||||
return rdr, nil
|
||||
return buf, nil
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -36,6 +36,15 @@ test_pins() {
|
||||
cat hashes | ipfs pin add $EXTRA_ARGS
|
||||
'
|
||||
|
||||
test_expect_success "see if verify works" '
|
||||
ipfs pin verify
|
||||
'
|
||||
|
||||
test_expect_success "see if verify --verbose works" '
|
||||
ipfs pin verify --verbose > verify_out &&
|
||||
test $(cat verify_out | wc -l) > 8
|
||||
'
|
||||
|
||||
test_expect_success "unpin those hashes" '
|
||||
cat hashes | ipfs pin rm
|
||||
'
|
||||
|
Reference in New Issue
Block a user