]> source.dussan.org Git - rspamd.git/commitdiff
Fix relearning for sqlite3 cache
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 11 Jan 2016 13:31:10 +0000 (13:31 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 11 Jan 2016 13:31:10 +0000 (13:31 +0000)
src/libstat/learn_cache/sqlite3_cache.c
src/libstat/stat_config.c

index 4bc8f0d06ba3e8caffdeb0688ad7fdbaf81fe4ce..7b46afefc8c508e08337bbfae23e4e90def3c14a 100644 (file)
@@ -133,7 +133,7 @@ rspamd_stat_cache_sqlite3_init (struct rspamd_stat_ctx *ctx,
        GError *err = NULL;
 
        if (cf) {
-               elt = ucl_object_find_key (cf, "path");
+               elt = ucl_object_find_any_key (cf, "path", "file", NULL);
 
                if (elt != NULL) {
                        path = ucl_object_tostring (elt);
@@ -252,9 +252,10 @@ rspamd_stat_cache_sqlite3_learn (struct rspamd_task *task,
        h = rspamd_mempool_get_variable (task->task_pool, "words_hash");
        g_assert (h != NULL);
 
+       flag = !!is_spam ? 1 : 0;
+
        if (!unlearn) {
                /* Insert result new id */
-               flag = !!is_spam ? 1 : 0;
                rspamd_sqlite3_run_prstmt (task->task_pool, ctx->db, ctx->prstmt,
                                RSPAMD_STAT_CACHE_TRANSACTION_START_IM);
                rspamd_sqlite3_run_prstmt (task->task_pool, ctx->db, ctx->prstmt,
@@ -267,7 +268,8 @@ rspamd_stat_cache_sqlite3_learn (struct rspamd_task *task,
                rspamd_sqlite3_run_prstmt (task->task_pool, ctx->db, ctx->prstmt,
                                RSPAMD_STAT_CACHE_TRANSACTION_START_IM);
                rspamd_sqlite3_run_prstmt (task->task_pool, ctx->db, ctx->prstmt,
-                               RSPAMD_STAT_CACHE_UPDATE_LEARN, task->task_pool,
+                               RSPAMD_STAT_CACHE_UPDATE_LEARN,
+                               flag,
                                (gint64)rspamd_cryptobox_HASHBYTES, h);
                rspamd_sqlite3_run_prstmt (task->task_pool, ctx->db, ctx->prstmt,
                                RSPAMD_STAT_CACHE_TRANSACTION_COMMIT);
index 50897b082d4c300cd39071ff3711717473648e5e..5e1a8672b5ad18bd6498f7ebe3e92d2c58ae7836 100644 (file)
@@ -157,7 +157,8 @@ rspamd_stat_init (struct rspamd_config *cfg, struct event_base *ev_base)
                        cache_name_obj = NULL;
 
                        if (cache_obj) {
-                               cache_name_obj = ucl_object_find_key (cache_obj, "name");
+                               cache_name_obj = ucl_object_find_any_key (cache_obj,
+                                               "name", "type", NULL);
                        }
 
                        if (cache_name_obj) {