@cryptotaxi247 / kubo / commits / a9417a144

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>

Jakub Sztandera committed Mar 4, 2018 at 01:24 UTC a9417a144c7aea9de12366bf78567bef6325075d
2 files changed +22 -15
core/commands/pin.go
+13 -15
@@ -462,25 +462,23 @@ var verifyPinCmd = &cmds.Command{
462 cmds.Text: func(res cmds.Response) (io.Reader, error) {
463 quiet, _, _ := res.Request().Option("quiet").Bool()
464
465 - outChan, ok := res.Output().(<-chan interface{})
465 + out, err := unwrapOutput(res.Output())
466 + if err != nil {
467 + return nil, err
468 + }
469 + r, ok := out.(*PinVerifyRes)
470 if !ok {
467 - return nil, u.ErrCast()
471 + return nil, e.TypeErr(r, out)
472 }
473
470 - rdr, wtr := io.Pipe()
471 - go func() {
472 - defer wtr.Close()
473 - for r0 := range outChan {
474 - r := r0.(*PinVerifyRes)
475 - if quiet && !r.Ok {
476 - fmt.Fprintf(wtr, "%s\n", r.Cid)
477 - } else if !quiet {
478 - r.Format(wtr)
479 - }
480 - }
481 - }()
474 + buf := &bytes.Buffer{}
475 + if quiet && !r.Ok {
476 + fmt.Fprintf(buf, "%s\n", r.Cid)
477 + } else if !quiet {
478 + r.Format(buf)
479 + }
480
483 - return rdr, nil
481 + return buf, nil
482 },
483 },
484 }
test/sharness/t0085-pins.sh
+9
@@ -36,6 +36,15 @@ test_pins() {
36 cat hashes | ipfs pin add $EXTRA_ARGS
37 '
38
39 + test_expect_success "see if verify works" '
40 + ipfs pin verify
41 + '
42 +
43 + test_expect_success "see if verify --verbose works" '
44 + ipfs pin verify --verbose > verify_out &&
45 + test $(cat verify_out | wc -l) > 8
46 + '
47 +
48 test_expect_success "unpin those hashes" '
49 cat hashes | ipfs pin rm
50 '