Skip to content

Commit

Permalink
fix: use EmitOnce where only single response is to be sent
Browse files Browse the repository at this point in the history
Part of #4818

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
  • Loading branch information
Kubuxu committed Mar 16, 2018
1 parent 682b263 commit 5917805
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func CommandsCmd(root *cmds.Command) *cmds.Command {
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) {
rootCmd := cmd2outputCmd("ipfs", root)
rootCmd.showOpts, _ = req.Options[flagsOptionName].(bool)
err := res.Emit(&rootCmd)
err := cmds.EmitOnce(res, &rootCmd)
if err != nil {
log.Error(err)
}
Expand Down
4 changes: 2 additions & 2 deletions core/commands/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ var filesStatCmd = &cmds.Command{
}

if !withLocal {
res.Emit(o)
cmds.EmitOnce(res, o)
return
}

Expand All @@ -161,7 +161,7 @@ var filesStatCmd = &cmds.Command{
o.Local = local
o.SizeLocal = sizeLocal

res.Emit(o)
cmds.EmitOnce(res, o)
},
Encoders: cmds.EncoderMap{
cmds.Text: cmds.MakeEncoder(func(req *cmds.Request, w io.Writer, v interface{}) error {
Expand Down

0 comments on commit 5917805

Please sign in to comment.