Mercurial > dovecot > core-2.2
changeset 12587:c3a258ee96c4
imapc: Don't send broken FETCH command when we don't actually have to fetch anything.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 20 Jan 2011 22:44:53 +0200 |
parents | a2780b694b2d |
children | 1b8fb4ff2bb3 |
files | src/lib-storage/index/imapc/imapc-search.c |
diffstat | 1 files changed, 8 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/imapc/imapc-search.c Thu Jan 20 20:59:07 2011 +0200 +++ b/src/lib-storage/index/imapc/imapc-search.c Thu Jan 20 22:44:53 2011 +0200 @@ -26,12 +26,15 @@ 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 @@ 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, ')');