mirror of
https://github.com/mjl-/mox.git
synced 2025-07-10 09:14:39 +03:00
fix bug with cli import command in case the mbox/maildir had keywords, future delivery to the mailbox would fail with duplicate uid's.
accounts with a mailbox with this problem can be fixed by running the "mox fixuidmeta <account>" command. we were resetting the mailbox uidnext after delivering messages when we were setting new keywords on the mailbox at the end of the import. so in a future delivery attempt to that mailbox, a uid would be chosen that was already present. the fix is to fetch the updated mailbox from the database before setting the new keywords. http/import.go doesn't have this bug because it was already fetching the mailbox before updating keywords (because it can import into many mailboxes, so different code). the "mox verifydata" command (recommended with backups) also warns about this issue (but doesn't fix it) found while working on new functionality (webmail).
This commit is contained in:
3
main.go
3
main.go
@ -2240,9 +2240,10 @@ open, or is not running.
|
||||
} else if err != nil {
|
||||
return fmt.Errorf("finding message with max uid in mailbox: %w", err)
|
||||
}
|
||||
olduidnext := mb.UIDNext
|
||||
mb.UIDNext = m.UID + 1
|
||||
log.Printf("fixing uidnext to %d (max uid is %d, old uidnext was %d) for mailbox %q (id %d)", mb.UIDNext, m.UID, olduidnext, mb.Name, mb.ID)
|
||||
if err := tx.Update(&mb); err != nil {
|
||||
log.Printf("fixing uidnext to %d (max uid is %d) for mailbox id %d", mb.UIDNext, m.UID, mb.ID)
|
||||
return fmt.Errorf("updating mailbox uidnext: %v", err)
|
||||
}
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user