mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 22:14:40 +03:00
update modseq when changing mailbox/server metadata, and also for specialuse changes, and keep track of modseq for mailboxes
i added the metadata extension to the imapserver recently. then i wondered how a client would efficiently find changed metadata. turns out the qresync rfc mentions that metadata changes should set a new modseq on the mailbox. shouldn't be hard, except that we were not explicitly keeping track of modseqs per mailbox. we only kept them for messages, and we were just looking up the latest message modseq when we needed the modseq (we keep db entries for expunged messages, so this worked out fine). that approach isn't enough anymore. so know we keep track of modseq & createseq for mailboxes, just as for messages. and we also track modseq/createseq for annotations. there's a good chance jmap is going to need it. this also adds consistency checks for modseq/createseq on mailboxes and annotations to the account storage. it helped spot cases i missed where the values need to be updated.
This commit is contained in:
@ -72,7 +72,6 @@ func TestMailbox(t *testing.T) {
|
||||
m.ThreadMuted = true
|
||||
m.ThreadCollapsed = true
|
||||
var mbsent Mailbox
|
||||
mbrejects := Mailbox{Name: "Rejects", UIDValidity: 1, UIDNext: 1, HaveCounts: true}
|
||||
mreject := m
|
||||
mconsumed := Message{
|
||||
Received: m.Received,
|
||||
@ -102,6 +101,9 @@ func TestMailbox(t *testing.T) {
|
||||
err = tx.Update(&mbsent)
|
||||
tcheck(t, err, "update mbsent")
|
||||
|
||||
modseq, err := acc.NextModSeq(tx)
|
||||
tcheck(t, err, "get next modseq")
|
||||
mbrejects := Mailbox{Name: "Rejects", UIDValidity: 1, UIDNext: 1, ModSeq: modseq, CreateSeq: modseq, HaveCounts: true}
|
||||
err = tx.Insert(&mbrejects)
|
||||
tcheck(t, err, "insert rejects mailbox")
|
||||
mreject.MailboxID = mbrejects.ID
|
||||
@ -166,20 +168,21 @@ func TestMailbox(t *testing.T) {
|
||||
t.Fatalf("same key for different address")
|
||||
}
|
||||
|
||||
var modseq ModSeq
|
||||
acc.WithWLock(func() {
|
||||
err := acc.DB.Write(ctxbg, func(tx *bstore.Tx) error {
|
||||
_, _, err := acc.MailboxEnsure(tx, "Testbox", true, SpecialUse{})
|
||||
_, _, err := acc.MailboxEnsure(tx, "Testbox", true, SpecialUse{}, &modseq)
|
||||
return err
|
||||
})
|
||||
tcheck(t, err, "ensure mailbox exists")
|
||||
err = acc.DB.Read(ctxbg, func(tx *bstore.Tx) error {
|
||||
_, _, err := acc.MailboxEnsure(tx, "Testbox", true, SpecialUse{})
|
||||
_, _, err := acc.MailboxEnsure(tx, "Testbox", true, SpecialUse{}, &modseq)
|
||||
return err
|
||||
})
|
||||
tcheck(t, err, "ensure mailbox exists")
|
||||
|
||||
err = acc.DB.Write(ctxbg, func(tx *bstore.Tx) error {
|
||||
_, _, err := acc.MailboxEnsure(tx, "Testbox2", false, SpecialUse{})
|
||||
_, _, err := acc.MailboxEnsure(tx, "Testbox2", false, SpecialUse{}, &modseq)
|
||||
tcheck(t, err, "create mailbox")
|
||||
|
||||
exists, err := acc.MailboxExists(tx, "Testbox2")
|
||||
|
Reference in New Issue
Block a user