aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libstat/learn_cache/redis_cache.c4
-rw-r--r--src/libstat/stat_process.c10
2 files changed, 12 insertions, 2 deletions
diff --git a/src/libstat/learn_cache/redis_cache.c b/src/libstat/learn_cache/redis_cache.c
index cd92bfac4..21f35a563 100644
--- a/src/libstat/learn_cache/redis_cache.c
+++ b/src/libstat/learn_cache/redis_cache.c
@@ -134,8 +134,7 @@ rspamd_stat_cache_redis_get (redisAsyncContext *c, gpointer r, gpointer priv)
if ((val > 0 && (task->flags & RSPAMD_TASK_FLAG_LEARN_SPAM)) ||
(val < 0 && (task->flags & RSPAMD_TASK_FLAG_LEARN_HAM))) {
/* Already learned */
- g_set_error (&task->err, rspamd_stat_quark (), 404,
- "<%s> has been already "
+ msg_info_task ("<%s> has been already "
"learned as %s, ignore it", task->message_id,
(task->flags & RSPAMD_TASK_FLAG_LEARN_SPAM) ? "spam" : "ham");
task->flags |= RSPAMD_TASK_FLAG_ALREADY_LEARNED;
@@ -144,6 +143,7 @@ rspamd_stat_cache_redis_get (redisAsyncContext *c, gpointer r, gpointer priv)
/* Unlearn flag */
task->flags |= RSPAMD_TASK_FLAG_UNLEARN;
}
+
rspamd_upstream_ok (rt->selected);
}
else {
diff --git a/src/libstat/stat_process.c b/src/libstat/stat_process.c
index ed24499ba..993de3816 100644
--- a/src/libstat/stat_process.c
+++ b/src/libstat/stat_process.c
@@ -547,6 +547,16 @@ rspamd_stat_classifiers_learn (struct rspamd_stat_ctx *st_ctx,
gint cb_ref;
gchar *cond_str = NULL;
+ if ((task->flags & RSPAMD_TASK_FLAG_ALREADY_LEARNED) && err != NULL &&
+ *err == NULL) {
+ /* Do not learn twice */
+ g_set_error (err, rspamd_stat_quark (), 404, "<%s> has been already "
+ "learned as %s, ignore it", task->message_id,
+ spam ? "spam" : "ham");
+
+ return FALSE;
+ }
+
/* Check whether we have learned that file */
for (i = 0; i < st_ctx->classifiers->len; i ++) {
cl = g_ptr_array_index (st_ctx->classifiers, i);