From 33b25be1b2d954b1edafa7dce8983fd8d9bd0fb7 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Mon, 25 Dec 2017 19:34:31 +0200 Subject: [PATCH] imapc: If mailbox select fails, rollback any changes done to it 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 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib-storage/index/imapc/imapc-mailbox.c b/src/lib-storage/index/imapc/imapc-mailbox.c index a07b27db88..013718998b 100644 --- a/src/lib-storage/index/imapc/imapc-mailbox.c +++ b/src/lib-storage/index/imapc/imapc-mailbox.c @@ -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; -- 2.47.3