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

commands: Refactored Command#Run function signature to (req Request, res Response)

This commit is contained in:
Matt Bell
2015-01-20 17:58:50 -08:00
parent 856d2896a7
commit 7b4de230eb
27 changed files with 426 additions and 236 deletions

View File

@ -36,26 +36,28 @@ order to reclaim hard disk space.
Options: []cmds.Option{
cmds.BoolOption("quiet", "q", "Write minimal output"),
},
Run: func(req cmds.Request) (interface{}, error) {
Run: func(req cmds.Request, res cmds.Response) {
n, err := req.Context().GetNode()
if err != nil {
return nil, err
res.SetError(err, cmds.ErrNormal)
return
}
gcOutChan, err := corerepo.GarbageCollectBlockstore(n, req.Context().Context)
if err != nil {
return nil, err
res.SetError(err, cmds.ErrNormal)
return
}
outChan := make(chan interface{})
res.SetOutput((<-chan interface{})(outChan))
go func() {
defer close(outChan)
for k := range gcOutChan {
outChan <- k
}
}()
return outChan, nil
},
Type: corerepo.KeyRemoved{},
Marshalers: cmds.MarshalerMap{