make code less indented

This commit is contained in:
Mechiel Lukkien 2025-03-05 17:34:57 +01:00
parent 577944310c
commit a5c64e4361
No known key found for this signature in database
2 changed files with 106 additions and 103 deletions

View File

@ -2943,11 +2943,23 @@ func (c *conn) cmdRename(tag, cmd string, p *parser) {
c.xdbwrite(func(tx *bstore.Tx) { c.xdbwrite(func(tx *bstore.Tx) {
srcMB := c.xmailbox(tx, src, "NONEXISTENT") srcMB := c.xmailbox(tx, src, "NONEXISTENT")
// Handle common/simple case first.
if src != "Inbox" {
var modseq store.ModSeq
var alreadyExists bool
var err error
changes, _, alreadyExists, err = c.account.MailboxRename(tx, &srcMB, dst, &modseq)
if alreadyExists {
xusercodeErrorf("ALREADYEXISTS", "%s", err)
}
xcheckf(err, "renaming mailbox")
return
}
// Inbox is very special. Unlike other mailboxes, its children are not moved. And // Inbox is very special. Unlike other mailboxes, its children are not moved. And
// unlike a regular move, its messages are moved to a newly created mailbox. We do // unlike a regular move, its messages are moved to a newly created mailbox. We do
// indeed create a new destination mailbox and actually move the messages. // indeed create a new destination mailbox and actually move the messages.
// ../rfc/9051:2101 // ../rfc/9051:2101
if src == "Inbox" {
exists, err := c.account.MailboxExists(tx, dst) exists, err := c.account.MailboxExists(tx, dst)
xcheckf(err, "checking if destination mailbox exists") xcheckf(err, "checking if destination mailbox exists")
if exists { if exists {
@ -2988,18 +3000,6 @@ func (c *conn) cmdRename(tag, cmd string, p *parser) {
newIDs, chl := c.xmoveMessages(tx, q, 0, modseq, &srcMB, &dstMB) newIDs, chl := c.xmoveMessages(tx, q, 0, modseq, &srcMB, &dstMB)
changes = append(changes, chl...) changes = append(changes, chl...)
cleanupIDs = newIDs cleanupIDs = newIDs
return
}
var modseq store.ModSeq
var alreadyExists bool
var err error
changes, _, alreadyExists, err = c.account.MailboxRename(tx, &srcMB, dst, &modseq)
if alreadyExists {
xusercodeErrorf("ALREADYEXISTS", "%s", err)
}
xcheckf(err, "renaming mailbox")
}) })
cleanupIDs = nil cleanupIDs = nil

View File

@ -713,8 +713,15 @@ func importMessages(ctx context.Context, log mlog.Log, token string, acc *store.
case "new", "cur", "tmp": case "new", "cur", "tmp":
mailbox := path.Dir(dir) mailbox := path.Dir(dir)
ximportMaildir(mailbox, origName, r) ximportMaildir(mailbox, origName, r)
default: return
if path.Base(name) == "dovecot-keywords" { }
if path.Base(name) != "dovecot-keywords" {
problemf("unrecognized file %s (skipping)", origName)
return
}
// Handle dovecot-keywords.
mailbox := path.Dir(name) mailbox := path.Dir(name)
dovecotKeywords := map[rune]string{} dovecotKeywords := map[rune]string{}
words, err := store.ParseDovecotKeywordsFlags(r, log) words, err := store.ParseDovecotKeywordsFlags(r, log)
@ -764,10 +771,6 @@ func importMessages(ctx context.Context, log mlog.Log, token string, acc *store.
changes = append(changes, m.ChangeFlags(oflags)) changes = append(changes, m.ChangeFlags(oflags))
} }
delete(mailboxMissingKeywordMessages, mailbox) delete(mailboxMissingKeywordMessages, mailbox)
} else {
problemf("unrecognized file %s (skipping)", origName)
}
}
} }
if zr != nil { if zr != nil {