From 0707f5336123f636060ffb3b34b2d2b6166b375c Mon Sep 17 00:00:00 2001 From: Mechiel Lukkien Date: Sat, 23 Sep 2023 12:15:13 +0200 Subject: [PATCH] in "mox uidbumpvalidity", bump to the next uidvalidity, otherwise we likely leave the uidvalidities in inconsistent state the inconsistent state isn't really harmful, but we don't want inconsistencies. pointed out in issue #61 by x8x --- doc.go | 2 +- main.go | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/doc.go b/doc.go index 4fb19c1..1157e86 100644 --- a/doc.go +++ b/doc.go @@ -807,7 +807,7 @@ Change the IMAP UID validity of the mailbox, causing IMAP clients to refetch mes This can be useful after manually repairing metadata about the account/mailbox. Opens account database file directly. Ensure mox does not have the account -+open, or is not running. +open, or is not running. usage: mox bumpuidvalidity account [mailbox] diff --git a/main.go b/main.go index 545779c..1c08cd5 100644 --- a/main.go +++ b/main.go @@ -2102,7 +2102,7 @@ func cmdBumpUIDValidity(c *cmd) { This can be useful after manually repairing metadata about the account/mailbox. Opens account database file directly. Ensure mox does not have the account -+open, or is not running. +open, or is not running. ` args := c.Parse() if len(args) != 1 && len(args) != 2 { @@ -2118,8 +2118,12 @@ Opens account database file directly. Ensure mox does not have the account } }() - var uidvalidity uint32 err = a.DB.Write(context.Background(), func(tx *bstore.Tx) error { + uidvalidity, err := a.NextUIDValidity(tx) + if err != nil { + return fmt.Errorf("assigning next uid validity: %v", err) + } + q := bstore.QueryTx[store.Mailbox](tx) if len(args) == 2 { q.FilterEqual("Name", args[1]) @@ -2132,8 +2136,7 @@ Opens account database file directly. Ensure mox does not have the account return fmt.Errorf("looking up mailbox %q, found %d mailboxes", args[1], len(mbl)) } for _, mb := range mbl { - mb.UIDValidity++ - uidvalidity = mb.UIDValidity + mb.UIDValidity = uidvalidity err = tx.Update(&mb) if err != nil { return fmt.Errorf("updating uid validity for mailbox: %v", err)