mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 12:24:38 +03:00
In storage consistency checks, verify the junk filter has the expected word counts
Fix up a test or two. Simplify the XOR logic when we train the junk filter: Only if junk or nonjunk is set, but not when both (or none are set). i.e. when the values aren't the same. Locking the account when we do consistency checks prevents spurious test failures that may have been introduced in the previous commit.
This commit is contained in:
@ -90,7 +90,7 @@ func (a *Account) RetrainMessages(ctx context.Context, log mlog.Log, tx *bstore.
|
||||
func (a *Account) RetrainMessage(ctx context.Context, log mlog.Log, tx *bstore.Tx, jf *junk.Filter, m *Message, absentOK bool) error {
|
||||
untrain := m.TrainedJunk != nil
|
||||
untrainJunk := untrain && *m.TrainedJunk
|
||||
train := m.Junk || m.Notjunk && !(m.Junk && m.Notjunk)
|
||||
train := m.Junk != m.Notjunk
|
||||
trainJunk := m.Junk
|
||||
|
||||
if !untrain && !train || (untrain && train && untrainJunk == trainJunk) {
|
||||
@ -144,7 +144,7 @@ func (a *Account) RetrainMessage(ctx context.Context, log mlog.Log, tx *bstore.T
|
||||
// TrainMessage trains the junk filter based on the current m.Junk/m.Notjunk flags,
|
||||
// disregarding m.TrainedJunk and not updating that field.
|
||||
func (a *Account) TrainMessage(ctx context.Context, log mlog.Log, jf *junk.Filter, m Message) (bool, error) {
|
||||
if !m.Junk && !m.Notjunk || (m.Junk && m.Notjunk) {
|
||||
if m.Junk == m.Notjunk {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user