]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Fix creating languages on learning.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 8 Sep 2015 18:09:14 +0000 (19:09 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 8 Sep 2015 18:09:14 +0000 (19:09 +0100)
src/libstat/backends/sqlite3_backend.c
src/libstat/stat_process.c

index 50c9886dfcafcfc6761b900ccd2ccc99e954e74e..a9299e31e806c3d0deed25b24044f09989b09a6c 100644 (file)
@@ -509,6 +509,16 @@ rspamd_sqlite3_init (struct rspamd_stat_ctx *ctx,
                                        bk->enable_languages = FALSE;
                                }
 
+                               if (bk->enable_languages) {
+                                       msg_info_config ("enable per language statistics for %s",
+                                                       stf->symbol);
+                               }
+
+                               if (bk->enable_users) {
+                                       msg_info_config ("enable per users statistics for %s",
+                                                       stf->symbol);
+                               }
+
                                ctx->statfiles ++;
 
                                curst = curst->next;
@@ -656,6 +666,9 @@ rspamd_sqlite3_finalize_process (struct rspamd_task *task, gpointer runtime,
                bk->in_transaction = FALSE;
        }
 
+       rt->lang_id = -1;
+       rt->user_id = -1;
+
        return;
 }
 
@@ -692,7 +705,7 @@ rspamd_sqlite3_learn_token (struct rspamd_task *task, struct token_node_s *tok,
        }
 
        if (rt->lang_id == -1) {
-               rt->lang_id = rspamd_sqlite3_get_language (bk, task, FALSE);
+               rt->lang_id = rspamd_sqlite3_get_language (bk, task, TRUE);
        }
 
        iv = res->value;
index 32367f9c423b3b9143570e56ffc2ddcf95317e06..d1e23baf2cfc94355d1c9b8905292fd1a7b5ba91 100644 (file)
@@ -708,6 +708,17 @@ rspamd_stat_learn (struct rspamd_task *task, gboolean spam, lua_State *L,
        while (cur) {
                cl_run = (struct rspamd_classifier_runtime *)cur->data;
 
+               curst = cl_run->st_runtime;
+
+               /* Needed to finalize pre-process stage */
+               while (curst) {
+                       st_run = curst->data;
+                       cl_run->backend->finalize_process (task,
+                                       st_run->backend_runtime,
+                                       cl_run->backend->ctx);
+                       curst = g_list_next (curst);
+               }
+
                if (cl_run->cl && !cl_run->skipped) {
                        cl_ctx = cl_run->cl->init_func (task->task_pool, cl_run->clcf);