]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imapc: Don't send broken FETCH command when we don't actually have to fetch anything.
authorTimo Sirainen <tss@iki.fi>
Thu, 20 Jan 2011 20:44:53 +0000 (22:44 +0200)
committerTimo Sirainen <tss@iki.fi>
Thu, 20 Jan 2011 20:44:53 +0000 (22:44 +0200)
src/lib-storage/index/imapc/imapc-search.c

index 60c323921c568d36758111b7f63a818c1d98e75d..9a9c599cdceeece2370e484c42ad87fa225ebc47 100644 (file)
@@ -26,12 +26,15 @@ bool imapc_search_next_nonblock(struct mail_search_context *_ctx,
        struct mail_private *pmail = (struct mail_private *)mail;
        struct imapc_mailbox *mbox = (struct imapc_mailbox *)mail->box;
        string_t *str;
+       unsigned int orig_len;
 
        if (!index_storage_search_next_nonblock(_ctx, mail, tryagain_r))
                return FALSE;
 
        str = t_str_new(64);
        str_printfa(str, "UID FETCH %u (", mail->uid);
+       orig_len = str_len(str);
+
        if ((pmail->wanted_fields & (MAIL_FETCH_MESSAGE_PARTS |
                                     MAIL_FETCH_NUL_STATE |
                                     MAIL_FETCH_IMAP_BODY |
@@ -48,6 +51,11 @@ bool imapc_search_next_nonblock(struct mail_search_context *_ctx,
        if ((pmail->wanted_fields & MAIL_FETCH_RECEIVED_DATE) != 0)
                str_append(str, "INTERNALDATE ");
 
+       if (str_len(str) == orig_len) {
+               /* we don't need to fetch anything */
+               return TRUE;
+       }
+
        str_truncate(str, str_len(str) - 1);
        str_append_c(str, ')');