Mercurial > dovecot > original-hg > dovecot-1.2
changeset 7582:8e7a15987428 HEAD
MAIL_FETCH_UIDL_BACKEND crashed with non-maildir backends. Changed the API a
bit and fixed/cleaned/optimized POP3 UIDL listing a bit.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 31 May 2008 13:47:11 +0300 |
parents | 89041c61c10b |
children | a99b9735f875 |
files | src/lib-storage/index/index-mail.c src/lib-storage/index/maildir/maildir-mail.c src/pop3/commands.c |
diffstat | 3 files changed, 48 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/index-mail.c Fri May 30 22:55:46 2008 +0300 +++ b/src/lib-storage/index/index-mail.c Sat May 31 13:47:11 2008 +0300 @@ -991,6 +991,7 @@ return 0; case MAIL_FETCH_FROM_ENVELOPE: case MAIL_FETCH_UIDL_FILE_NAME: + case MAIL_FETCH_UIDL_BACKEND: *value_r = ""; return 0; case MAIL_FETCH_HEADER_MD5:
--- a/src/lib-storage/index/maildir/maildir-mail.c Fri May 30 22:55:46 2008 +0300 +++ b/src/lib-storage/index/maildir/maildir-mail.c Sat May 31 13:47:11 2008 +0300 @@ -430,12 +430,8 @@ } else if (field == MAIL_FETCH_UIDL_BACKEND) { uidl = maildir_uidlist_lookup_ext(mbox->uidlist, _mail->uid, MAILDIR_UIDLIST_REC_EXT_POP3_UIDL); - if (uidl != NULL) { - *value_r = uidl; - return 0; - } else { - return -1; - } + *value_r = uidl != NULL ? uidl : ""; + return 0; } return index_mail_get_special(_mail, field, value_r);
--- a/src/pop3/commands.c Fri May 30 22:55:46 2008 +0300 +++ b/src/pop3/commands.c Sat May 31 13:47:11 2008 +0300 @@ -506,6 +506,49 @@ struct mail_search_seqset seqset; }; +static void pop3_get_uid(struct cmd_uidl_context *ctx, + struct var_expand_table *tab, string_t *str) +{ + char uid_str[MAX_INT_STRLEN]; + const char *uidl; + + if (mail_get_special(ctx->mail, MAIL_FETCH_UIDL_BACKEND, &uidl) == 0 && + *uidl != '\0') { + str_append(str, uidl); + return; + } + + if (reuse_xuidl && + mail_get_first_header(ctx->mail, "X-UIDL", &uidl) > 0) { + str_append(str, uidl); + return; + } + + if ((uidl_keymask & UIDL_UID) != 0) { + i_snprintf(uid_str, sizeof(uid_str), "%u", + ctx->mail->uid); + tab[1].value = uid_str; + } + if ((uidl_keymask & UIDL_MD5) != 0) { + if (mail_get_special(ctx->mail, MAIL_FETCH_HEADER_MD5, + &tab[2].value) < 0 || + *tab[2].value == '\0') { + /* broken */ + i_fatal("UIDL: Header MD5 not found"); + } + } + if ((uidl_keymask & UIDL_FILE_NAME) != 0) { + if (mail_get_special(ctx->mail, + MAIL_FETCH_UIDL_FILE_NAME, + &tab[3].value) < 0 || + *tab[3].value == '\0') { + /* broken */ + i_fatal("UIDL: File name not found"); + } + } + var_expand(str, uidl_format, tab); +} + static bool list_uids_iter(struct client *client, struct cmd_uidl_context *ctx) { static struct var_expand_table static_tab[] = { @@ -517,8 +560,6 @@ }; struct var_expand_table *tab; string_t *str; - char uid_str[MAX_INT_STRLEN]; - const char *uidl; int ret; bool found = FALSE; @@ -536,41 +577,11 @@ } found = TRUE; - if ((uidl_keymask & UIDL_UID) != 0) { - i_snprintf(uid_str, sizeof(uid_str), "%u", - ctx->mail->uid); - tab[1].value = uid_str; - } - if ((uidl_keymask & UIDL_MD5) != 0) { - if (mail_get_special(ctx->mail, MAIL_FETCH_HEADER_MD5, - &tab[2].value) < 0 || - *tab[2].value == '\0') { - /* broken */ - i_fatal("UIDL: Header MD5 not found"); - } - } - if ((uidl_keymask & UIDL_FILE_NAME) != 0) { - if (mail_get_special(ctx->mail, - MAIL_FETCH_UIDL_FILE_NAME, - &tab[3].value) < 0 || - *tab[3].value == '\0') { - /* broken */ - i_fatal("UIDL: File name not found"); - } - } - str_truncate(str, 0); str_printfa(str, ctx->message == 0 ? "%u " : "+OK %u ", ctx->mail->seq); - - if (mail_get_special(ctx->mail, MAIL_FETCH_UIDL_BACKEND, - &uidl) == 0) - str_append(str, uidl); - else if (reuse_xuidl && - mail_get_first_header(ctx->mail, "X-UIDL", &uidl) > 0) - str_append(str, uidl); - else - var_expand(str, uidl_format, tab); + pop3_get_uid(ctx, tab, str); + ret = client_send_line(client, "%s", str_c(str)); if (ret < 0) break;