]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] configwizard: check version matching 2067/head
authorAlexander Moisseev <moiseev@mezonplus.ru>
Sun, 11 Mar 2018 16:13:50 +0000 (19:13 +0300)
committerAlexander Moisseev <moiseev@mezonplus.ru>
Sun, 11 Mar 2018 18:14:09 +0000 (21:14 +0300)
lualib/rspamadm/configwizard.lua

index 07923df067fe07dc4b9549d647e66292feaea9c1..21a1fa580ea46daa79a82275dd88c95e25b8d3c9 100644 (file)
@@ -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)