aboutsummaryrefslogtreecommitdiffstats
path: root/lualib/rspamadm/configwizard.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-03-14 14:01:47 +0000
committerGitHub <noreply@github.com>2018-03-14 14:01:47 +0000
commit75a629f31a36537a64ee2b988e7460229d3adc1f (patch)
tree6b888951c5c0ff327b07e8dbf7a1adf7f9e8bf68 /lualib/rspamadm/configwizard.lua
parenta32bcc60f1e80fa3d351ae0a050b5fc13f48dc5a (diff)
parentaa99e4aed71b189182607aa0dcfaab3796b9c965 (diff)
downloadrspamd-75a629f31a36537a64ee2b988e7460229d3adc1f.tar.gz
rspamd-75a629f31a36537a64ee2b988e7460229d3adc1f.zip
Merge pull request #2067 from moisseev/configwizard
[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 65e289d47..7299cb275 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)