diff --git a/store/account.go b/store/account.go index d10f9bc..9dacbe3 100644 --- a/store/account.go +++ b/store/account.go @@ -671,14 +671,12 @@ func (a *Account) DeliverX(log *mlog.Log, tx *bstore.Tx, m *Message, msgFile *os xcheckf(err, "sync directory") } - if notrain && m.NeedsTraining() { - // If this ever happens, hopefully we'll get bug reports about it. - log.Error("deliver of message that unexpectedly needs training", mlog.Field("messageid", m.ID), mlog.Field("trainedjunk", m.TrainedJunk), mlog.Field("flags", m.Flags)) + if !notrain && m.NeedsTraining() { + l := []Message{*m} + err = a.RetrainMessages(log, tx, l, false) + xcheckf(err, "training junkfilter") + *m = l[0] } - l := []Message{*m} - err = a.RetrainMessages(log, tx, l, false) - xcheckf(err, "training junkfilter") - *m = l[0] } // write contents of r to new file dst, for delivering a message. diff --git a/store/train.go b/store/train.go index 6c8b980..818e44a 100644 --- a/store/train.go +++ b/store/train.go @@ -2,6 +2,7 @@ package store import ( "errors" + "fmt" "os" "path/filepath" @@ -63,6 +64,8 @@ func (a *Account) RetrainMessages(log *mlog.Log, tx *bstore.Tx, msgs []Message, if err != nil && errors.Is(err, ErrNoJunkFilter) { // No junk filter configured. Nothing more to do. return nil + } else if err != nil { + return fmt.Errorf("open junk filter: %v", err) } defer func() { if jf != nil {