mirror of
https://github.com/mjl-/mox.git
synced 2024-12-27 08:53:48 +03:00
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
This commit is contained in:
parent
85cef2a06c
commit
0707f53361
2 changed files with 8 additions and 5 deletions
2
doc.go
2
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.
|
This can be useful after manually repairing metadata about the account/mailbox.
|
||||||
|
|
||||||
Opens account database file directly. Ensure mox does not have the account
|
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]
|
usage: mox bumpuidvalidity account [mailbox]
|
||||||
|
|
||||||
|
|
11
main.go
11
main.go
|
@ -2102,7 +2102,7 @@ func cmdBumpUIDValidity(c *cmd) {
|
||||||
This can be useful after manually repairing metadata about the account/mailbox.
|
This can be useful after manually repairing metadata about the account/mailbox.
|
||||||
|
|
||||||
Opens account database file directly. Ensure mox does not have the account
|
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()
|
args := c.Parse()
|
||||||
if len(args) != 1 && len(args) != 2 {
|
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 {
|
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)
|
q := bstore.QueryTx[store.Mailbox](tx)
|
||||||
if len(args) == 2 {
|
if len(args) == 2 {
|
||||||
q.FilterEqual("Name", args[1])
|
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))
|
return fmt.Errorf("looking up mailbox %q, found %d mailboxes", args[1], len(mbl))
|
||||||
}
|
}
|
||||||
for _, mb := range mbl {
|
for _, mb := range mbl {
|
||||||
mb.UIDValidity++
|
mb.UIDValidity = uidvalidity
|
||||||
uidvalidity = mb.UIDValidity
|
|
||||||
err = tx.Update(&mb)
|
err = tx.Update(&mb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("updating uid validity for mailbox: %v", err)
|
return fmt.Errorf("updating uid validity for mailbox: %v", err)
|
||||||
|
|
Loading…
Reference in a new issue