From 237d4b22848ae10ecfadd62acbd2714c7463e967 Mon Sep 17 00:00:00 2001 From: mike kabischev Date: Wed, 8 Feb 2017 14:16:54 +0300 Subject: [PATCH] fix #143 broken hook data --- controller/fence.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/controller/fence.go b/controller/fence.go index 92ebfc78..ebc2ecbd 100644 --- a/controller/fence.go +++ b/controller/fence.go @@ -150,12 +150,12 @@ func fenceMatch(hookName string, sw *scanWriter, fence *liveFenceSwitches, metas sw.fullFields = true sw.msg.OutputType = server.JSON sw.writeObject(ScanWriterParams{ - id:details.id, - o: details.obj, + id: details.id, + o: details.obj, fields: details.fields, noLock: true, }) - + if sw.wr.Len() == 0 { sw.mu.Unlock() return nil @@ -194,10 +194,13 @@ func fenceMatch(hookName string, sw *scanWriter, fence *liveFenceSwitches, metas msgs := make([][]byte, 0, 4) if fence.detect == nil || fence.detect[detect] { - if len(res) > 0 && res[0] == '{' { - res = makemsg(details.command, group, detect, hookName, metas, details.key, details.timestamp, res[1:]) + if fence.detect == nil || fence.detect[detect] { + if len(res) > 0 && res[0] == '{' { + msgs = append(msgs, makemsg(details.command, group, detect, hookName, metas, details.key, details.timestamp, res[1:])) + } else { + msgs = append(msgs, res) + } } - msgs = append(msgs, res) } switch detect { case "enter":