aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstat/stat_process.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-21 12:48:05 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-21 12:48:24 +0100
commit6b106e1cbbf814e34b6950bc9ad205a758bbfb22 (patch)
treeea43055c1694e508c9a2c2117bea473f07a06087 /src/libstat/stat_process.c
parent4152bff2f4b8ca5fe9a8e5a2edcaa84d120e7843 (diff)
downloadrspamd-6b106e1cbbf814e34b6950bc9ad205a758bbfb22.tar.gz
rspamd-6b106e1cbbf814e34b6950bc9ad205a758bbfb22.zip
[Fix] Fix learning for non-existent backend
Diffstat (limited to 'src/libstat/stat_process.c')
-rw-r--r--src/libstat/stat_process.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/libstat/stat_process.c b/src/libstat/stat_process.c
index 49585af66..5c39cd8d8 100644
--- a/src/libstat/stat_process.c
+++ b/src/libstat/stat_process.c
@@ -601,7 +601,7 @@ rspamd_stat_backends_learn (struct rspamd_stat_ctx *st_ctx,
gpointer bk_run;
guint i, j;
gint id;
- gboolean res = TRUE;
+ gboolean res = FALSE;
for (i = 0; i < st_ctx->classifiers->len; i ++) {
cl = g_ptr_array_index (st_ctx->classifiers, i);
@@ -640,6 +640,7 @@ rspamd_stat_backends_learn (struct rspamd_stat_ctx *st_ctx,
}
res = FALSE;
+ goto end;
}
else {
if (!!spam == !!st->stcf->is_spam) {
@@ -648,10 +649,13 @@ rspamd_stat_backends_learn (struct rspamd_stat_ctx *st_ctx,
else if (task->flags & RSPAMD_TASK_FLAG_UNLEARN) {
st->backend->dec_learns (task, bk_run, st_ctx);
}
+
+ res = TRUE;
}
}
}
+end:
if (sel == NULL) {
if (classifier) {
g_set_error (err, rspamd_stat_quark (), 404, "cannot find classifier "
@@ -664,6 +668,12 @@ rspamd_stat_backends_learn (struct rspamd_stat_ctx *st_ctx,
return FALSE;
}
+ if (!res) {
+ g_set_error (err, rspamd_stat_quark (), 404, "cannot find statfile "
+ "backend to learn %s in %s", spam ? "spam" : "ham",
+ classifier ? classifier : "default classifier");
+ }
+
return res;
}