mirror of
https://github.com/mjl-/mox.git
synced 2024-12-27 08:53:48 +03:00
remove message during delivery when we encounter an error after having placed the message in the destination path
before, we would leave the file, but rollback the delivery. future deliveries would attempt to deliver to the same path, but would fail because a file already exists. encountered during testing on windows, not during actual operation. though it could in theory have happened.
This commit is contained in:
parent
6e391c3be0
commit
3e53343d21
1 changed files with 4 additions and 0 deletions
|
@ -1349,6 +1349,8 @@ func (a *Account) DeliverMessage(log *mlog.Log, tx *bstore.Tx, m *Message, msgFi
|
||||||
|
|
||||||
if sync {
|
if sync {
|
||||||
if err := moxio.SyncDir(msgDir); err != nil {
|
if err := moxio.SyncDir(msgDir); err != nil {
|
||||||
|
xerr := os.Remove(msgPath)
|
||||||
|
log.Check(xerr, "removing message after syncdir error", mlog.Field("path", msgPath))
|
||||||
return fmt.Errorf("sync directory: %w", err)
|
return fmt.Errorf("sync directory: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1356,6 +1358,8 @@ func (a *Account) DeliverMessage(log *mlog.Log, tx *bstore.Tx, m *Message, msgFi
|
||||||
if !notrain && m.NeedsTraining() {
|
if !notrain && m.NeedsTraining() {
|
||||||
l := []Message{*m}
|
l := []Message{*m}
|
||||||
if err := a.RetrainMessages(context.TODO(), log, tx, l, false); err != nil {
|
if err := a.RetrainMessages(context.TODO(), log, tx, l, false); err != nil {
|
||||||
|
xerr := os.Remove(msgPath)
|
||||||
|
log.Check(xerr, "removing message after syncdir error", mlog.Field("path", msgPath))
|
||||||
return fmt.Errorf("training junkfilter: %w", err)
|
return fmt.Errorf("training junkfilter: %w", err)
|
||||||
}
|
}
|
||||||
*m = l[0]
|
*m = l[0]
|
||||||
|
|
Loading…
Reference in a new issue