]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imapc: If mailbox select fails, rollback any changes done to it
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 25 Dec 2017 17:34:31 +0000 (19:34 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Thu, 18 Jan 2018 10:07:06 +0000 (12:07 +0200)
Required by the following changes that start adding changes immediately
after SELECT. If the initial syncing doesn't finish successfully, these
changes need to be reverted.

src/lib-storage/index/imapc/imapc-mailbox.c

index a07b27db88a50febfdaa3fbf504768c4b739d2e7..013718998b445015eeb67ec1c567ef9a3f0e7846 100644 (file)
@@ -100,7 +100,12 @@ int imapc_mailbox_commit_delayed_trans(struct imapc_mailbox *mbox,
 
        if (mbox->delayed_sync_view != NULL)
                mail_index_view_close(&mbox->delayed_sync_view);
-       if (mbox->delayed_sync_trans != NULL) {
+       if (mbox->delayed_sync_trans == NULL)
+               ;
+       else if (!mbox->selected) {
+               /* ignore any changes done during SELECT */
+               mail_index_transaction_rollback(&mbox->delayed_sync_trans);
+       } else {
                if (mail_index_transaction_commit(&mbox->delayed_sync_trans) < 0) {
                        mailbox_set_index_error(&mbox->box);
                        ret = -1;