1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-30 18:13:54 +08:00

block rm: use Marshalers instead of PostRun to process output

License: MIT
Signed-off-by: Kevin Atkinson <k@kevina.org>
This commit is contained in:
Kevin Atkinson
2017-02-19 21:02:39 -05:00
parent 584c095647
commit 4115e2315d

View File

@ -280,21 +280,19 @@ It takes a list of base58 encoded multihashs to remove.
}
res.SetOutput(ch)
},
PostRun: func(req cmds.Request, res cmds.Response) {
if res.Error() != nil {
return
}
outChan, ok := res.Output().(<-chan interface{})
if !ok {
res.SetError(u.ErrCast(), cmds.ErrNormal)
return
}
res.SetOutput(nil)
Marshalers: cmds.MarshalerMap{
cmds.Text: func(res cmds.Response) (io.Reader, error) {
outChan, ok := res.Output().(<-chan interface{})
if !ok {
return nil, u.ErrCast()
}
err := util.ProcRmOutput(outChan, res.Stdout(), res.Stderr())
if err != nil {
res.SetError(err, cmds.ErrNormal)
}
err := util.ProcRmOutput(outChan, res.Stdout(), res.Stderr())
if err != nil {
return nil, err
}
return nil, nil
},
},
Type: util.RemovedBlock{},
}