From 70d0787fcb1d2fd1db2b64bfa948e91d3dd54fb9 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 11 Jan 2016 13:31:10 +0000 Subject: [PATCH] Fix relearning for sqlite3 cache --- src/libstat/learn_cache/sqlite3_cache.c | 8 +++++--- src/libstat/stat_config.c | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/libstat/learn_cache/sqlite3_cache.c b/src/libstat/learn_cache/sqlite3_cache.c index 4bc8f0d06..7b46afefc 100644 --- a/src/libstat/learn_cache/sqlite3_cache.c +++ b/src/libstat/learn_cache/sqlite3_cache.c @@ -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); diff --git a/src/libstat/stat_config.c b/src/libstat/stat_config.c index 50897b082..5e1a8672b 100644 --- a/src/libstat/stat_config.c +++ b/src/libstat/stat_config.c @@ -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) { -- 2.39.5