From: Alexander Moisseev Date: Sun, 11 Mar 2018 16:13:50 +0000 (+0300) Subject: [Minor] configwizard: check version matching X-Git-Tag: 1.7.1~48^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2067%2Fhead;p=thirdparty%2Frspamd.git [Minor] configwizard: check version matching --- diff --git a/lualib/rspamadm/configwizard.lua b/lualib/rspamadm/configwizard.lua index 07923df067..21a1fa580e 100644 --- a/lualib/rspamadm/configwizard.lua +++ b/lualib/rspamadm/configwizard.lua @@ -371,10 +371,21 @@ end return ver ]] + conn:add_cmd('EVAL', {lua_script, '1', symbol_ham}) + local _,ver_ham = conn:exec() + conn:add_cmd('EVAL', {lua_script, '1', symbol_spam}) - local _,ver = conn:exec() + local _,ver_spam = conn:exec() - return tonumber(ver) + -- If one of the classes is missing we still can convert the other one + if ver_ham == 0 and ver_spam == 0 and ver_ham ~= ver_spam then + printf("Current statistics versions do not match: %s -> %s, %s -> %s", + symbol_ham, ver_ham, symbol_spam, ver_spam) + printf("Cannot convert statistics") + return false + end + + return true,tonumber(ver_ham) end local function check_expire(conn) @@ -404,8 +415,8 @@ return ttl end if not cls.new_schema then - local ver = get_version(conn) - + local r,ver = get_version(conn) + if not r then return false end if ver ~= 2 then printf("You are using an old schema for %s/%s", symbol_ham, symbol_spam) try_convert(true) @@ -425,7 +436,8 @@ return ttl end end else - local ver = get_version(conn) + local r,ver = get_version(conn) + if not r then return false end if ver ~= 2 then printf("You have configured new schema for %s/%s but your DB has old data", symbol_spam, symbol_ham)