diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-07-18 17:15:33 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-07-18 17:15:33 +0400 |
commit | 5eb0717f2e58711f850c3f99f7163c105fda12c5 (patch) | |
tree | 32abc9d7c52b5b867fbdabffa1b502c2d5906aa0 | |
parent | df48852be53a1822537e55e846723ee49bb421c5 (diff) | |
download | rspamd-5eb0717f2e58711f850c3f99f7163c105fda12c5.tar.gz rspamd-5eb0717f2e58711f850c3f99f7163c105fda12c5.zip |
Create statfiles using learn_spam function for bayes classifier.
Fix call of pre callbacks for a classifier.
-rw-r--r-- | src/classifiers/bayes.c | 18 | ||||
-rw-r--r-- | src/lua/lua_classifier.c | 2 |
2 files changed, 19 insertions, 1 deletions
diff --git a/src/classifiers/bayes.c b/src/classifiers/bayes.c index 5998d0fdb..f45f84a38 100644 --- a/src/classifiers/bayes.c +++ b/src/classifiers/bayes.c @@ -397,6 +397,24 @@ bayes_learn_spam (struct classifier_ctx* ctx, statfile_pool_t *pool, if ((file = statfile_pool_is_open (pool, st->path)) == NULL) { if ((file = statfile_pool_open (pool, st->path, st->size, FALSE)) == NULL) { msg_warn ("cannot open %s", st->path); + if (statfile_pool_create (pool, st->path, st->size) == -1) { + msg_err ("cannot create statfile %s", st->path); + g_set_error (err, + bayes_error_quark(), /* error domain */ + 1, /* error code */ + "cannot create statfile: %s", + st->path); + return FALSE; + } + if ((file = statfile_pool_open (pool, st->path, st->size, FALSE)) == NULL) { + g_set_error (err, + bayes_error_quark(), /* error domain */ + 1, /* error code */ + "cannot open statfile %s after creation", + st->path); + msg_err ("cannot open statfile %s after creation", st->path); + return FALSE; + } cur = g_list_next (cur); continue; } diff --git a/src/lua/lua_classifier.c b/src/lua/lua_classifier.c index 511767680..901d6cff5 100644 --- a/src/lua/lua_classifier.c +++ b/src/lua/lua_classifier.c @@ -144,7 +144,7 @@ call_classifier_pre_callbacks (struct classifier_config *ccf, struct worker_task lua_pushstring (L, ccf->classifier->name); lua_gettable (L, -2); /* Function is now on top */ - if (lua_isfunction (L, 1)) { + if (lua_isfunction (L, -1)) { res = call_classifier_pre_callback (ccf, task, L, is_learn, is_spam); } } |