]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imapc: Keep "selected" state TRUE only while mailbox is successfully SELECTed
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 25 Dec 2017 17:33:33 +0000 (19:33 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 18 Jan 2018 07:12:31 +0000 (09:12 +0200)
src/lib-storage/index/imapc/imapc-storage.c

index 5a2aeb583e7fdfa68e56d47c2614c80b62b3735b..c16e6aa0bd33bcdbb2d787fd53f465a9a3b48a6a 100644 (file)
@@ -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) {