]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imapc: Move expunging from index to imapc_mailbox_index_expunge()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sat, 16 Jun 2018 12:08:26 +0000 (15:08 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 26 Jun 2018 08:28:51 +0000 (11:28 +0300)
src/lib-storage/index/imapc/imapc-mailbox.c

index a023e3f70e6a3cd064fa6a6a7be06f85b3428b09..ca01841d723d3cd6be14833d6181a96d62b13321 100644 (file)
@@ -157,6 +157,26 @@ static void imapc_mailbox_idle_notify(struct imapc_mailbox *mbox)
        }
 }
 
+static void
+imapc_mailbox_index_expunge(struct imapc_mailbox *mbox, uint32_t uid)
+{
+       uint32_t lseq;
+
+       if (mail_index_lookup_seq(mbox->sync_view, uid, &lseq))
+               mail_index_expunge(mbox->delayed_sync_trans, lseq);
+       else if (mail_index_lookup_seq(mbox->delayed_sync_view, uid, &lseq)) {
+               /* this message exists only in this transaction. lib-index
+                  can't currently handle expunging anything except the last
+                  appended message in a transaction, and fixing it would be
+                  quite a lot of trouble. so instead we'll just delay doing
+                  this expunge until after the current transaction has been
+                  committed. */
+               seq_range_array_add(&mbox->delayed_expunged_uids, uid);
+       } else {
+               /* already expunged by another session */
+       }
+}
+
 static void
 imapc_mailbox_fetch_state_finish(struct imapc_mailbox *mbox)
 {
@@ -602,7 +622,7 @@ static void imapc_untagged_expunge(const struct imapc_untagged_reply *reply,
                                   struct imapc_mailbox *mbox)
 {
        struct imapc_msgmap *msgmap;
-       uint32_t lseq, uid, rseq = reply->num;
+       uint32_t uid, rseq = reply->num;
        
        if (mbox == NULL || rseq == 0 ||
            IMAPC_BOX_HAS_FEATURE(mbox, IMAPC_FEATURE_NO_MSN_UPDATES))
@@ -629,19 +649,7 @@ static void imapc_untagged_expunge(const struct imapc_untagged_reply *reply,
                array_delete(&mbox->rseq_modseqs, rseq-1, 1);
 
        imapc_mailbox_init_delayed_trans(mbox);
-       if (mail_index_lookup_seq(mbox->sync_view, uid, &lseq))
-               mail_index_expunge(mbox->delayed_sync_trans, lseq);
-       else if (mail_index_lookup_seq(mbox->delayed_sync_view, uid, &lseq)) {
-               /* this message exists only in this transaction. lib-index
-                  can't currently handle expunging anything except the last
-                  appended message in a transaction, and fixing it would be
-                  quite a lot of trouble. so instead we'll just delay doing
-                  this expunge until after the current transaction has been
-                  committed. */
-               seq_range_array_add(&mbox->delayed_expunged_uids, uid);
-       } else {
-               /* already expunged by another session */
-       }
+       imapc_mailbox_index_expunge(mbox, uid);
        imapc_mailbox_idle_notify(mbox);
 }