From 24f312aae440cf8a99df443a38235b6f2cdb05ed Mon Sep 17 00:00:00 2001 From: Alexander Moisseev Date: Sat, 10 Mar 2018 19:09:08 +0300 Subject: [PATCH] [Minor] Abort classifier checks if failed to connect to Redis --- lualib/rspamadm/configwizard.lua | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lualib/rspamadm/configwizard.lua b/lualib/rspamadm/configwizard.lua index d42f4c3f3d..efe91f6eb2 100644 --- a/lualib/rspamadm/configwizard.lua +++ b/lualib/rspamadm/configwizard.lua @@ -357,8 +357,7 @@ local function check_redis_classifier(cls, changes) end end - local function get_version() - local _,conn = lua_redis.redis_connect_sync(parsed_redis, true) + local function get_version(conn) -- We still need to check versions local lua_script = [[ local ver = 0 @@ -376,8 +375,7 @@ return ver return tonumber(ver) end - local function check_expire() - local _,conn = lua_redis.redis_connect_sync(parsed_redis, true) + local function check_expire(conn) -- We still need to check versions local lua_script = [[ local ttl = 0 @@ -397,8 +395,14 @@ return ttl return tonumber(ttl) end + local res,conn = lua_redis.redis_connect_sync(parsed_redis, true) + if not res then + printf("Cannot connect to Redis server") + return false + end + if not cls.new_schema then - local ver = get_version() + local ver = get_version(conn) if ver ~= 2 then printf("You are using an old schema for %s/%s", symbol_ham, symbol_spam) @@ -412,14 +416,14 @@ return ttl new_schema = true, } - local expire = check_expire() + local expire = check_expire(conn) if expire then changes.l['classifier-bayes.conf'].expire = expire end end end else - local ver = get_version() + local ver = get_version(conn) if ver ~= 2 then printf("You have configured new schema for %s/%s but your DB has old data", symbol_spam, symbol_ham) -- 2.47.3