# HG changeset patch # User Timo Sirainen # Date 1514223213 -7200 # Node ID ca2de1a908585cba1a6974049bb6000e1922e67d # Parent ffccd1d964b39845d855f5e9d574a855ab493bf8 imapc: Keep "selected" state TRUE only while mailbox is successfully SELECTed diff -r ffccd1d964b3 -r ca2de1a90858 src/lib-storage/index/imapc/imapc-storage.c --- 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) {