commit 6b7c9ef: [Minor] Fix work with file names

Vsevolod Stakhov vsevolod at highsecure.ru
Fri Apr 30 16:56:08 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-04-30 17:51:45 +0100
URL: https://github.com/rspamd/rspamd/commit/6b7c9efcb81b67b5293428813badd2c57416a75f (HEAD -> master)

[Minor] Fix work with file names

---
 lualib/rspamadm/statistics_dump.lua | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lualib/rspamadm/statistics_dump.lua b/lualib/rspamadm/statistics_dump.lua
index bbd4e2410..ab4e026c5 100644
--- a/lualib/rspamadm/statistics_dump.lua
+++ b/lualib/rspamadm/statistics_dump.lua
@@ -378,7 +378,7 @@ local function execute_batch(batch, conns, opts)
 end
 
 local function restore_handler(opts)
-  local files = opts.files or {'-'}
+  local files = opts.file or {'-'}
   local conns = {}
 
   for _,cls in ipairs(classifiers) do
@@ -395,8 +395,10 @@ local function restore_handler(opts)
   local batch = {}
 
   for _,f in ipairs(files) do
+    local fd
     if f ~= '-' then
-      io.input(f)
+      fd = io.open(f, 'r')
+      io.input(fd)
     end
 
     local cur_line = 1
@@ -418,6 +420,8 @@ local function restore_handler(opts)
         batch = {}
       end
     end
+
+    if fd then fd:close() end
   end
 
   if #batch > 0 then


More information about the Commits mailing list