]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imapc: Added a Courier-workaround for not returning UIDNEXT on SELECT.
authorTimo Sirainen <tss@iki.fi>
Tue, 29 Oct 2013 17:42:14 +0000 (19:42 +0200)
committerTimo Sirainen <tss@iki.fi>
Tue, 29 Oct 2013 17:42:14 +0000 (19:42 +0200)
src/lib-storage/index/imapc/imapc-storage.c

index 2e9d7d8458fd6d0393788f08ccfd7341578aaa3f..cffe06564beb31e1d0dbbe608f8200f977478d75 100644 (file)
@@ -669,7 +669,7 @@ static int imapc_mailbox_delete(struct mailbox *box)
        return index_storage_mailbox_delete(box);
 }
 
-static int imapc_mailbox_get_status(struct mailbox *box,
+static int imapc_mailbox_run_status(struct mailbox *box,
                                    enum mailbox_status_items items,
                                    struct mailbox_status *status_r)
 {
@@ -678,25 +678,6 @@ static int imapc_mailbox_get_status(struct mailbox *box,
        struct imapc_simple_context sctx;
        string_t *str;
 
-       if (mbox->guid_fetch_field_name != NULL ||
-           IMAPC_BOX_HAS_FEATURE(mbox, IMAPC_FEATURE_GUID_FORCED))
-               status_r->have_guids = TRUE;
-
-       if (box->opened) {
-               imapc_mailbox_get_selected_status(mbox, items, status_r);
-               return 0;
-       }
-
-       /* mailbox isn't opened yet */
-       if ((items & (STATUS_FIRST_UNSEEN_SEQ | STATUS_KEYWORDS |
-                     STATUS_PERMANENT_FLAGS)) != 0) {
-               /* getting these requires opening the mailbox */
-               if (mailbox_open(box) < 0)
-                       return -1;
-               imapc_mailbox_get_selected_status(mbox, items, status_r);
-               return 0;
-       }
-
        str = t_str_new(256);
        if ((items & STATUS_MESSAGES) != 0)
                str_append(str, " MESSAGES");
@@ -726,6 +707,38 @@ static int imapc_mailbox_get_status(struct mailbox *box,
        return sctx.ret;
 }
 
+static int imapc_mailbox_get_status(struct mailbox *box,
+                                   enum mailbox_status_items items,
+                                   struct mailbox_status *status_r)
+{
+       struct imapc_mailbox *mbox = (struct imapc_mailbox *)box;
+
+       if (mbox->guid_fetch_field_name != NULL ||
+           IMAPC_BOX_HAS_FEATURE(mbox, IMAPC_FEATURE_GUID_FORCED))
+               status_r->have_guids = TRUE;
+
+       if (box->opened) {
+               imapc_mailbox_get_selected_status(mbox, items, status_r);
+       } else if ((items & (STATUS_FIRST_UNSEEN_SEQ | STATUS_KEYWORDS |
+                            STATUS_PERMANENT_FLAGS)) != 0) {
+               /* getting these requires opening the mailbox */
+               if (mailbox_open(box) < 0)
+                       return -1;
+               imapc_mailbox_get_selected_status(mbox, items, status_r);
+       } else {
+               if (imapc_mailbox_run_status(box, items, status_r) < 0)
+                       return -1;
+       }
+
+       if (box->opened && (items & STATUS_UIDNEXT) != 0 &&
+           mbox->sync_uid_next == 0) {
+               /* Courier-workaround, it doesn't send UIDNEXT on SELECT */
+               if (imapc_mailbox_run_status(box, STATUS_UIDNEXT, status_r) < 0)
+                       return -1;
+       }
+       return 0;
+}
+
 static int imapc_mailbox_get_namespaces(struct imapc_storage *storage)
 {
        enum imapc_capability capa;