mirror of
https://github.com/mjl-/mox.git
synced 2025-06-28 10:58:16 +03:00
consistently use store.CloseRemoveTempFile for closing and removing temp files
This commit is contained in:
parent
b822533df3
commit
3050baa15a
@ -6,7 +6,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
@ -270,11 +269,7 @@ func (mr *MaildirReader) 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 maildir read error")
|
||||
err = os.Remove(name)
|
||||
mr.log.Check(err, "removing temporary message file after maildir read error", slog.String("path", name))
|
||||
CloseRemoveTempFile(mr.log, f, "maildir temp message file")
|
||||
}
|
||||
}()
|
||||
|
||||
|
@ -385,7 +385,7 @@ func importMessages(ctx context.Context, log mlog.Log, token string, acc *store.
|
||||
|
||||
// For maildirs, we are likely to get a possible dovecot-keywords file after having
|
||||
// imported the messages. Once we see the keywords, we use them. But before that
|
||||
// time we remember which messages miss a keywords. Once the keywords become
|
||||
// time we remember which messages miss keywords. Once the keywords become
|
||||
// available, we'll fix up the flags for the unknown messages
|
||||
mailboxKeywords := map[string]map[rune]string{} // Mailbox to 'a'-'z' to flag name.
|
||||
mailboxMissingKeywordMessages := map[string]map[int64]string{} // Mailbox to message id to string consisting of the unrecognized flags.
|
||||
@ -501,13 +501,7 @@ func importMessages(ctx context.Context, log mlog.Log, token string, acc *store.
|
||||
}
|
||||
|
||||
xdeliver := func(mb store.Mailbox, m *store.Message, f *os.File, pos string) {
|
||||
defer func() {
|
||||
name := f.Name()
|
||||
err = f.Close()
|
||||
log.Check(err, "closing temporary message file for delivery")
|
||||
err := os.Remove(name)
|
||||
log.Check(err, "removing temporary message file for delivery")
|
||||
}()
|
||||
defer store.CloseRemoveTempFile(log, f, "message file for import")
|
||||
m.MailboxID = mb.ID
|
||||
m.MailboxOrigID = mb.ID
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user