From ce651ecc1cdfcc630334a95e9e65cede4989065f Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Mon, 25 Dec 2017 19:33:33 +0200 Subject: [PATCH] imapc: Keep "selected" state TRUE only while mailbox is successfully SELECTed --- src/lib-storage/index/imapc/imapc-storage.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib-storage/index/imapc/imapc-storage.c b/src/lib-storage/index/imapc/imapc-storage.c index 5a2aeb583e..c16e6aa0bd 100644 --- a/src/lib-storage/index/imapc/imapc-storage.c +++ b/src/lib-storage/index/imapc/imapc-storage.c @@ -579,8 +579,10 @@ imapc_mailbox_reopen_callback(const struct imapc_command_reply *reply, 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, @@ -611,6 +613,7 @@ static void imapc_mailbox_reopen(void *context) mbox->initial_sync_done = FALSE; mbox->selecting = TRUE; + mbox->selected = FALSE; mbox->exists_received = FALSE; cmd = imapc_client_mailbox_cmd(mbox->client_box, @@ -637,13 +640,13 @@ imapc_mailbox_open_callback(const struct imapc_command_reply *reply, 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)) { mailbox_set_critical(&ctx->mbox->box, "imapc: Opening mailbox failed: %s", error); ctx->ret = -1; } else { + ctx->mbox->selected = TRUE; ctx->ret = 0; } } else if (reply->state == IMAPC_COMMAND_STATE_NO) { -- 2.47.3