From: Andrew Lewis Date: Wed, 8 Mar 2017 10:36:59 +0000 (+0200) Subject: [Fix] Fix log line duplication in `rspamadm grep` X-Git-Tag: 1.5.3~78^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1500%2Fhead;p=thirdparty%2Frspamd.git [Fix] Fix log line duplication in `rspamadm grep` - Reported by: @croessner --- diff --git a/src/rspamadm/grep.lua b/src/rspamadm/grep.lua index c5527680bb..e49977a1dd 100644 --- a/src/rspamadm/grep.lua +++ b/src/rspamadm/grep.lua @@ -1,7 +1,6 @@ return function(_, res) local rspamd_regexp = require 'rspamd_regexp' - local E = {} local buffer = {} local matches = {} @@ -47,9 +46,11 @@ return function(_, res) else for line in h:lines() do local hash = string.match(line, '^%d+-%d+-%d+ %d+:%d+:%d+ #%d+%(%a+%) <(%x+)>') + local already_matching = false if hash then if matches[hash] then table.insert(matches[hash], line) + already_matching = true else if buffer[hash] then table.insert(buffer[hash], line) @@ -74,14 +75,8 @@ return function(_, res) print(line) print() end - else - if matches[hash] then - table.insert(matches[hash], line) - else - local cur = buffer[hash] or E - table.insert(cur, line) - matches[hash] = cur - end + elseif not already_matching then + matches[hash] = buffer[hash] end end local is_end = string.match(line, '^%d+-%d+-%d+ %d+:%d+:%d+ #%d+%(%a+%) <%x+>; task; rspamd_protocol_http_reply:')