aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-02-26 11:45:18 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-02-26 11:45:18 +0000
commitac04a740a831c712c93bacb40a4a230131c89281 (patch)
tree7bf07940bc0ff49552da1ed78197778792980881
parent39b50a5708cf8fa33c50f33bd63656da260d659e (diff)
downloadrspamd-ac04a740a831c712c93bacb40a4a230131c89281.tar.gz
rspamd-ac04a740a831c712c93bacb40a4a230131c89281.zip
[Minor] Check Redis layout before converting
-rw-r--r--lualib/rspamadm/configwizard.lua33
1 files changed, 28 insertions, 5 deletions
diff --git a/lualib/rspamadm/configwizard.lua b/lualib/rspamadm/configwizard.lua
index 3d3530b0c..b5bff38ce 100644
--- a/lualib/rspamadm/configwizard.lua
+++ b/lualib/rspamadm/configwizard.lua
@@ -351,10 +351,7 @@ local function check_redis_classifier(cls, changes)
end
end
- if not cls.new_schema then
- printf("You are using an old schema for %s/%s", symbol_ham, symbol_spam)
- try_convert()
- else
+ local function get_version()
local _,conn = lua_redis.redis_connect_sync(parsed_redis, true)
-- We still need to check versions
local lua_script = [[
@@ -369,7 +366,33 @@ return ver
]]
conn:add_cmd('EVAL', {lua_script, '1', symbol_spam})
local _,ver = conn:exec()
- if tonumber(ver) ~= 2 then
+
+ return tonumber(ver)
+ end
+
+ if not cls.new_schema then
+ local ver = get_version()
+
+ if ver ~= 2 then
+ printf("You are using an old schema for %s/%s", symbol_ham, symbol_spam)
+ try_convert()
+ else
+ printf("You have configured an old schema for %s/%s but your data has new layout",
+ symbol_ham, symbol_spam)
+
+ if ask_yes_no("Switch config to the new schema?", true) then
+ changes.l['classifier_bayes'] = {
+ new_schema = true,
+ }
+
+ if expire then
+ changes.l['classifier_bayes'].expire = expire
+ end
+ end
+ end
+ else
+ local ver = get_version()
+ if ver ~= 2 then
printf("You have configured new schema for %s/%s but your DB has old data",
symbol_spam, symbol_ham)
try_convert()