Mercurial > dovecot > original-hg > dovecot-1.2
changeset 7787:ad51fc17da67 HEAD
Dummy root fix
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 13 May 2008 02:29:41 +0300 |
parents | 8f6fa7aa0236 |
children | 3718262bec49 |
files | src/imap/imap-thread-finish.c |
diffstat | 1 files changed, 22 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap/imap-thread-finish.c Tue May 13 02:00:28 2008 +0300 +++ b/src/imap/imap-thread-finish.c Tue May 13 02:29:41 2008 +0300 @@ -518,7 +518,6 @@ const struct mail_thread_node *node; int ret; - str_append_c(str, '('); if (!root->dummy) { node = mail_hash_lookup_idx(ctx->hash_trans, root->node.idx); i_assert(node->uid != 0 && node->exists); @@ -537,15 +536,13 @@ if (ret < 0) return -1; } - - str_append_c(str, ')'); return 0; } static int send_roots(struct thread_finish_context *ctx) { const struct mail_thread_root_node *roots; - unsigned int i, count; + unsigned int i, count, child_count; string_t *str; int ret = 0; @@ -553,13 +550,30 @@ str_append(str, "* THREAD "); roots = array_get(&ctx->roots, &count); - for (i = 0; i < count; i++) { - if (!roots[i].ignore) { - if (send_root(ctx, str, &roots[i]) < 0) { - ret = -1; + /* see if we have only one child */ + for (i = 0, child_count = 0; i < count && child_count < 2; i++) { + if (!roots[i].ignore) + child_count++; + } + if (child_count == 1) { + for (i = 0; i < count; i++) { + if (!roots[i].ignore) { + if (!roots[i].dummy) + str_append_c(str, '('); + ret = send_root(ctx, str, &roots[i]); + if (!roots[i].dummy) + str_append_c(str, ')'); break; } } + } else { + for (i = 0; i < count && ret == 0; i++) { + if (!roots[i].ignore) { + str_append_c(str, '('); + ret = send_root(ctx, str, &roots[i]); + str_append_c(str, ')'); + } + } } if (ret == 0) {