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

commands: Cleanup Requests after command execution returns

This commit is contained in:
Matt Bell
2014-11-12 00:05:57 -08:00
committed by Juan Batiz-Benet
parent 8c9ee52a93
commit 81dbb23602
2 changed files with 24 additions and 0 deletions

View File

@ -97,6 +97,14 @@ func (c *Command) Call(req Request) Response {
return res
}
// clean up the request (close the readers, e.g. fileargs)
// NOTE: this means commands can't expect to keep reading after cmd.Run returns (in a goroutine)
err = req.Cleanup()
if err != nil {
res.SetError(err, ErrNormal)
return res
}
res.SetOutput(output)
return res
}