aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-01-11 13:31:10 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-01-11 13:31:10 +0000
commit70d0787fcb1d2fd1db2b64bfa948e91d3dd54fb9 (patch)
treeff46135faa35b6c16cc875b252b6b184ed517569
parent54fc24c2b369399915f9470cbfef4146858df0eb (diff)
downloadrspamd-70d0787fcb1d2fd1db2b64bfa948e91d3dd54fb9.tar.gz
rspamd-70d0787fcb1d2fd1db2b64bfa948e91d3dd54fb9.zip
Fix relearning for sqlite3 cache
-rw-r--r--src/libstat/learn_cache/sqlite3_cache.c8
-rw-r--r--src/libstat/stat_config.c3
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) {