aboutsummaryrefslogtreecommitdiffstats
path: root/lualib/rspamadm/configwizard.lua
diff options
context:
space:
mode:
authorAlexander Moisseev <moiseev@mezonplus.ru>2018-03-11 19:13:50 +0300
committerAlexander Moisseev <moiseev@mezonplus.ru>2018-03-11 21:14:09 +0300
commitaa99e4aed71b189182607aa0dcfaab3796b9c965 (patch)
tree8bd049a70f1ee3932d0f40ef5dccc0bccbc6295f /lualib/rspamadm/configwizard.lua
parentd27d7084c5e8516a2fa670bf680245f6884adfbb (diff)
downloadrspamd-aa99e4aed71b189182607aa0dcfaab3796b9c965.tar.gz
rspamd-aa99e4aed71b189182607aa0dcfaab3796b9c965.zip
[Minor] configwizard: check version matching
Diffstat (limited to 'lualib/rspamadm/configwizard.lua')
-rw-r--r--lualib/rspamadm/configwizard.lua22
1 files changed, 17 insertions, 5 deletions
diff --git a/lualib/rspamadm/configwizard.lua b/lualib/rspamadm/configwizard.lua
index 07923df06..21a1fa580 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)