changeset 22758:ca2de1a90858

imapc: Keep "selected" state TRUE only while mailbox is successfully SELECTed
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Mon, 25 Dec 2017 19:33:33 +0200
parents ffccd1d964b3
children a83edde46a15
files src/lib-storage/index/imapc/imapc-storage.c
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/imapc/imapc-storage.c	Wed Jan 17 15:05:38 2018 +0200
+++ b/src/lib-storage/index/imapc/imapc-storage.c	Mon Dec 25 19:33:33 2017 +0200
@@ -577,8 +577,10 @@
 	mbox->selecting = FALSE;
 	if (reply->state != IMAPC_COMMAND_STATE_OK)
 		errmsg = reply->text_full;
-	else if (imapc_mailbox_verify_select(mbox, &errmsg))
+	else if (imapc_mailbox_verify_select(mbox, &errmsg)) {
 		errmsg = NULL;
+		mbox->selected = TRUE;
+	}
 
 	if (errmsg != NULL) {
 		imapc_client_mailbox_reconnect(mbox->client_box,
@@ -609,6 +611,7 @@
 
 	mbox->initial_sync_done = FALSE;
 	mbox->selecting = TRUE;
+	mbox->selected = FALSE;
 	mbox->exists_received = FALSE;
 
 	cmd = imapc_client_mailbox_cmd(mbox->client_box,
@@ -635,7 +638,6 @@
 	const char *error;
 
 	ctx->mbox->selecting = FALSE;
-	ctx->mbox->selected = TRUE;
 	if (reply->state == IMAPC_COMMAND_STATE_OK) {
 		if (!imapc_mailbox_verify_select(ctx->mbox, &error)) {
 			mail_storage_set_critical(ctx->mbox->box.storage,
@@ -643,6 +645,7 @@
 				ctx->mbox->box.name, error);
 			ctx->ret = -1;
 		} else {
+			ctx->mbox->selected = TRUE;
 			ctx->ret = 0;
 		}
 	} else if (reply->state == IMAPC_COMMAND_STATE_NO) {