]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Check sqlite databases before conversation
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 12 Mar 2018 15:48:41 +0000 (15:48 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 12 Mar 2018 15:48:41 +0000 (15:48 +0000)
lualib/rspamadm/configwizard.lua

index 07923df067fe07dc4b9549d647e66292feaea9c1..25e665aa01a4cf57ccf3cd064aa803e4dbaa5cef 100644 (file)
@@ -452,17 +452,24 @@ local function setup_statistic(cfg, changes)
         '100d')
       expire = lua_util.parse_time_interval(expire)
 
+
       local reset_previous = ask_yes_no("Reset previuous data?")
       if ask_yes_no('Do you wish to convert them to Redis?', true) then
 
         for _,cls in ipairs(sqlite_configs) do
-          if not lua_stat_tools.convert_sqlite_to_redis(parsed_redis, cls.db_spam,
-            cls.db_ham, cls.symbol_spam, cls.symbol_ham, cls.learn_cache, expire,
-            reset_previous) then
-            rspamd_logger.errx('conversion failed')
+          if rspamd_util.file_exists(cls.db_spam) and rspamd_util.file_exists(cls.db_ham) then
+            if not lua_stat_tools.convert_sqlite_to_redis(parsed_redis, cls.db_spam,
+                cls.db_ham, cls.symbol_spam, cls.symbol_ham, cls.learn_cache, expire,
+                reset_previous) then
+              rspamd_logger.errx('conversion failed')
 
-            return false
+              return false
+            end
+          else
+            rspamd_logger.messagex('cannot find %s and %s, skip conversation',
+                cls.db_spam, cls.db_ham)
           end
+
           rspamd_logger.messagex('Converted classifier to the from sqlite to redis')
           changes.l['classifier-bayes.conf'] = {
             backend = 'redis',