mirror of
https://github.com/mjl-/mox.git
synced 2025-07-14 01:34:37 +03:00
junk filter: fix adjusting word counts after train/untrain
after seeing some junk messages pass the filter, i investigated word counts in junkfilter.db. i had seen suspicious counts that were just around powers of two. did not make sense at the time. more investigating makes it clear: instead of setting new word counts when updating the junk filter, we were adding the new value to the current value (instead of just setting the new value). so the counts got approximately doubled when being updated. users should retrain the junk filter after this update using the "retrain" subcommand. this also adds logging for the hypothetical case where numbers would get decreased below zero (which would wrap around due to uints). and this fixes junk filter tests that were passing wrong parameters to train/untrain...
This commit is contained in:
@ -126,7 +126,7 @@ func TestFilter(t *testing.T) {
|
||||
tcheck(t, err, "train spam message")
|
||||
_, err = spamf.Seek(0, 0)
|
||||
tcheck(t, err, "seek spam message")
|
||||
err = f.TrainMessage(ctxbg, spamf, spamsize, true)
|
||||
err = f.TrainMessage(ctxbg, spamf, spamsize, false)
|
||||
tcheck(t, err, "train spam message")
|
||||
|
||||
if !f.modified {
|
||||
@ -166,16 +166,16 @@ func TestFilter(t *testing.T) {
|
||||
tcheck(t, err, "untrain ham message")
|
||||
_, err = hamf.Seek(0, 0)
|
||||
tcheck(t, err, "seek ham message")
|
||||
err = f.UntrainMessage(ctxbg, hamf, spamsize, true)
|
||||
err = f.UntrainMessage(ctxbg, hamf, hamsize, true)
|
||||
tcheck(t, err, "untrain ham message")
|
||||
|
||||
_, err = spamf.Seek(0, 0)
|
||||
tcheck(t, err, "seek spam message")
|
||||
err = f.UntrainMessage(ctxbg, spamf, spamsize, true)
|
||||
err = f.UntrainMessage(ctxbg, spamf, spamsize, false)
|
||||
tcheck(t, err, "untrain spam message")
|
||||
_, err = spamf.Seek(0, 0)
|
||||
tcheck(t, err, "seek spam message")
|
||||
err = f.UntrainMessage(ctxbg, spamf, spamsize, true)
|
||||
err = f.UntrainMessage(ctxbg, spamf, spamsize, false)
|
||||
tcheck(t, err, "untrain spam message")
|
||||
|
||||
if !f.modified {
|
||||
|
Reference in New Issue
Block a user