dovecot-1.0: Don't get message's header and body sizes separatel...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Nov 28 08:11:24 EET 2007
details: http://hg.dovecot.org/dovecot-1.0/rev/edd95f9c6ba4
changeset: 5464:edd95f9c6ba4
user: Timo Sirainen <tss at iki.fi>
date: Wed Nov 28 08:11:17 2007 +0200
description:
Don't get message's header and body sizes separately if we really only need
the full size.
diffstat:
1 file changed, 23 insertions(+), 11 deletions(-)
src/imap/imap-fetch-body.c | 34 +++++++++++++++++++++++-----------
diffs (75 lines):
diff -r 0fba164c6ba6 -r edd95f9c6ba4 src/imap/imap-fetch-body.c
--- a/src/imap/imap-fetch-body.c Wed Nov 28 08:10:17 2007 +0200
+++ b/src/imap/imap-fetch-body.c Wed Nov 28 08:11:17 2007 +0200
@@ -326,9 +326,19 @@ static int fetch_body(struct imap_fetch_
const struct message_size *fetch_size;
struct message_size hdr_size, body_size;
- ctx->cur_input =
- mail_get_stream(mail, &hdr_size,
- body->section[0] == 'H' ? NULL : &body_size);
+ if (body->section[0] == '\0') {
+ 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)
+ return -1;
+ } else {
+ ctx->cur_input = mail_get_stream(mail, &hdr_size,
+ body->section[0] == 'H' ?
+ NULL : &body_size);
+ }
if (ctx->cur_input == NULL)
return -1;
@@ -338,7 +348,6 @@ static int fetch_body(struct imap_fetch_
switch (body->section[0]) {
case '\0':
/* BODY[] - fetch everything */
- message_size_add(&body_size, &hdr_size);
fetch_size = &body_size;
break;
case 'H':
@@ -874,21 +883,24 @@ static int fetch_rfc822(struct imap_fetc
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;
+
+ 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)
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;
}
@@ -896,8 +908,8 @@ static int fetch_rfc822(struct imap_fetc
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,
More information about the dovecot-cvs
mailing list