]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix log line duplication in `rspamadm grep` 1500/head
authorAndrew Lewis <nerf@judo.za.org>
Wed, 8 Mar 2017 10:36:59 +0000 (12:36 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Wed, 8 Mar 2017 12:38:07 +0000 (14:38 +0200)
 - Reported by: @croessner

src/rspamadm/grep.lua

index c5527680bbdc21410269c9366fcf3296e883f436..e49977a1ddb4258fa73130f5ce093a1f04d84e10 100644 (file)
@@ -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:')