From 395c1e6847a3a7162c7415175700076355f8ecd0 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 21 Feb 2018 15:45:12 +0000 Subject: [PATCH] [Fix] Fix various issues in stat_convert --- lualib/lua_redis.lua | 2 ++ lualib/rspamadm/stat_convert.lua | 2 +- lualib/stat_tools.lua | 7 ++++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lualib/lua_redis.lua b/lualib/lua_redis.lua index c01cdfae9..2102db841 100644 --- a/lualib/lua_redis.lua +++ b/lualib/lua_redis.lua @@ -914,6 +914,8 @@ local function redis_connect_sync(redis_params, is_write, key, cfg) if not ret then logger.errx('cannot execute redis request: %s', conn) addr:fail() + + return false,nil,addr end if conn then diff --git a/lualib/rspamadm/stat_convert.lua b/lualib/rspamadm/stat_convert.lua index 31c37880a..f70581fa4 100644 --- a/lualib/rspamadm/stat_convert.lua +++ b/lualib/rspamadm/stat_convert.lua @@ -1,4 +1,4 @@ -local lua_redis = require "rspamd_redis" +local lua_redis = require "lua_redis" local stat_tools = require "stat_tools" local ucl = require "ucl" local logger = require "rspamd_logger" diff --git a/lualib/stat_tools.lua b/lualib/stat_tools.lua index f969f1000..f952ec9a9 100644 --- a/lualib/stat_tools.lua +++ b/lualib/stat_tools.lua @@ -223,7 +223,7 @@ end if is_spam then hash_key = 'S' end - for _,tok in tokens do + for _,tok in ipairs(tokens) do -- tok schema: -- tok[1] = token_id (uint64 represented as a string) -- tok[2] = token value (number) @@ -356,8 +356,9 @@ end end end - logger.messagex('Migrated %d tokens for %d users for symbol %s', - total, nusers, res['symbol']) + logger.messagex('Migrated %s tokens for %s users for symbols (%s, %s)', + total, nusers, symbol_spam, symbol_ham) + return true end exports.convert_sqlite_to_redis = convert_sqlite_to_redis -- 2.39.5