refactor common pattern of close & remove temporary file into calling the new store.CloseRemoveTempFile

This commit is contained in:
Mechiel Lukkien
2023-11-01 18:57:38 +01:00
parent b6897d1837
commit ef50f4abf0
11 changed files with 15 additions and 81 deletions

View File

@ -84,11 +84,7 @@ func (mr *MboxReader) Next() (*Message, *os.File, string, error) {
}
defer func() {
if f != nil {
name := f.Name()
err := f.Close()
mr.log.Check(err, "closing temporary message file after mbox read error")
err = os.Remove(name)
mr.log.Check(err, "removing temporary message file after mbox read error", mlog.Field("path", name))
CloseRemoveTempFile(mr.log, f, "message after mbox read error")
}
}()