Mercurial > dovecot > original-hg > dovecot-1.0
changeset 5498:fc5f6bbbf4c0 branch_1_0
Put back mail_get_stream() optimizations now that mail_get_physical_size()
works properly.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 22 Dec 2007 06:53:33 +0200 |
parents | 0713de760c5f |
children | 0a4f86976f50 |
files | src/imap/imap-fetch-body.c |
diffstat | 1 files changed, 21 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap/imap-fetch-body.c Sat Dec 22 06:51:57 2007 +0200 +++ b/src/imap/imap-fetch-body.c Sat Dec 22 06:53:33 2007 +0200 @@ -327,13 +327,15 @@ struct message_size hdr_size, body_size; if (body->section[0] == '\0') { - /* FIXME: We really wouldn't have to know header size here - specifically, but with mbox mail_get_physical_size() returns - the real current size on disk, not the size that the stream - has. This may cause virtual_size==physical_size and break - our checks. */ - ctx->cur_input = mail_get_stream(mail, &hdr_size, &body_size); - message_size_add(&body_size, &hdr_size); + ctx->cur_input = mail_get_stream(mail, NULL, NULL); + + body_size.virtual_size = mail_get_virtual_size(mail); + body_size.physical_size = mail_get_physical_size(mail); + if (body_size.virtual_size == (uoff_t)-1 || + body_size.physical_size == (uoff_t)-1) { + ctx->cur_input = NULL; + return -1; + } } else { ctx->cur_input = mail_get_stream(mail, &hdr_size, body->section[0] == 'H' ? @@ -883,22 +885,27 @@ 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; - ctx->cur_input = mail_get_stream(mail, &hdr_size, &body_size); + ctx->cur_input = mail_get_stream(mail, NULL, NULL); if (ctx->cur_input == NULL) return -1; - /* FIXME: Same problem as with fetch_body() */ - message_size_add(&body_size, &hdr_size); + size.virtual_size = mail_get_virtual_size(mail); + size.physical_size = mail_get_physical_size(mail); + if (size.virtual_size == (uoff_t)-1 || + size.physical_size == (uoff_t)-1) { + ctx->cur_input = NULL; + return -1; + } i_stream_ref(ctx->cur_input); ctx->update_partial = FALSE; 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; } @@ -906,8 +913,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,