Skip to content

Commit

Permalink
remove message during delivery when we encounter an error after havin…
Browse files Browse the repository at this point in the history
…g 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.
  • Loading branch information
mjl- committed Oct 14, 2023
1 parent 6e391c3 commit 3e53343
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions store/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -1349,13 +1349,17 @@ func (a *Account) DeliverMessage(log *mlog.Log, tx *bstore.Tx, m *Message, msgFi

if sync {
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)
}
}

if !notrain && m.NeedsTraining() {
l := []Message{*m}
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)
}
*m = l[0]
Expand Down

0 comments on commit 3e53343

Please sign in to comment.