Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6866:b223a34c64cb HEAD
Don't get message's header and body sizes separately if we really only need
the full size.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 28 Nov 2007 08:11:18 +0200 |
parents | 5c48dc658d78 |
children | 901467b1506e |
files | src/imap/imap-fetch-body.c |
diffstat | 1 files changed, 21 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap/imap-fetch-body.c Wed Nov 28 08:10:18 2007 +0200 +++ b/src/imap/imap-fetch-body.c Wed Nov 28 08:11:18 2007 +0200 @@ -325,10 +325,18 @@ const struct message_size *fetch_size; struct message_size hdr_size, body_size; - if (mail_get_stream(mail, &hdr_size, - body->section[0] == 'H' ? NULL : &body_size, - &ctx->cur_input) < 0) - return -1; + if (body->section[0] == '\0') { + if (mail_get_stream(mail, NULL, NULL, &ctx->cur_input) < 0) + return -1; + if (mail_get_virtual_size(mail, &body_size.virtual_size) < 0 || + mail_get_physical_size(mail, &body_size.physical_size) < 0) + return -1; + } else { + if (mail_get_stream(mail, &hdr_size, + body->section[0] == 'H' ? NULL : &body_size, + &ctx->cur_input) < 0) + return -1; + } i_stream_ref(ctx->cur_input); ctx->update_partial = TRUE; @@ -336,7 +344,6 @@ switch (body->section[0]) { case '\0': /* BODY[] - fetch everything */ - message_size_add(&body_size, &hdr_size); fetch_size = &body_size; break; case 'H': @@ -866,20 +873,22 @@ static int fetch_rfc822(struct imap_fetch_context *ctx, struct mail *mail, void *context ATTR_UNUSED) { - struct message_size hdr_size, body_size; + struct message_size size; const char *str; - if (mail_get_stream(mail, &hdr_size, &body_size, &ctx->cur_input) < 0) + if (mail_get_stream(mail, NULL, NULL, &ctx->cur_input) < 0) + return -1; + + if (mail_get_virtual_size(mail, &size.virtual_size) < 0 || + mail_get_physical_size(mail, &size.physical_size) < 0) return -1; i_stream_ref(ctx->cur_input); ctx->update_partial = FALSE; - message_size_add(&body_size, &hdr_size); - if (ctx->cur_offset == 0) { str = t_strdup_printf(" RFC822 {%"PRIuUOFF_T"}\r\n", - body_size.virtual_size); + size.virtual_size); if (ctx->first) { str++; ctx->first = FALSE; } @@ -887,8 +896,8 @@ return -1; } - ctx->cur_size = body_size.virtual_size; - return fetch_stream(ctx, &body_size); + ctx->cur_size = size.virtual_size; + return fetch_stream(ctx, &size); } static int fetch_rfc822_header(struct imap_fetch_context *ctx,