dovecot-1.0: mail_get_physical_size() returns now the mail strea...

dovecot at dovecot.org dovecot at dovecot.org
Sat Dec 22 06:53:42 EET 2007


details:   http://hg.dovecot.org/dovecot-1.0/rev/0713de760c5f
changeset: 5497:0713de760c5f
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Dec 22 06:51:57 2007 +0200
description:
mail_get_physical_size() returns now the mail stream's size.
mail_get_stream()'s body_size optimizations rely on this.

diffstat:

1 file changed, 15 insertions(+), 10 deletions(-)
src/lib-storage/index/mbox/mbox-mail.c |   25 +++++++++++++++----------

diffs (47 lines):

diff -r 6555158a78c7 -r 0713de760c5f src/lib-storage/index/mbox/mbox-mail.c
--- a/src/lib-storage/index/mbox/mbox-mail.c	Sat Dec 22 03:17:47 2007 +0200
+++ b/src/lib-storage/index/mbox/mbox-mail.c	Sat Dec 22 06:51:57 2007 +0200
@@ -158,18 +158,22 @@ static uoff_t mbox_mail_get_physical_siz
 	struct index_mail_data *data = &mail->data;
 	struct mbox_mailbox *mbox = (struct mbox_mailbox *)mail->ibox;
 	const struct mail_index_header *hdr;
-	struct istream *stream;
-	uoff_t hdr_offset, body_offset, body_size;
-	uoff_t next_offset;
+	struct istream *input;
+	struct message_size hdr_size;
+	uoff_t size, body_offset, body_size, next_offset;
 	bool deleted;
 
-	if (mbox_mail_seek(mail) <= 0)
+	size = index_mail_get_physical_size(_mail);
+	if (size != (uoff_t)-1)
+		return size;
+
+	/* we want to return the header size as seen by mail_get_stream(). */
+	input = mail_get_stream(_mail, &hdr_size, NULL);
+	if (input == NULL)
 		return (uoff_t)-1;
 
 	/* our header size varies, so don't do any caching */
-	stream = mbox->mbox_stream;
-	hdr_offset = istream_raw_mbox_get_header_offset(stream);
-	body_offset = istream_raw_mbox_get_body_offset(stream);
+	body_offset = istream_raw_mbox_get_body_offset(mbox->mbox_stream);
 	if (body_offset == (uoff_t)-1)
 		return (uoff_t)-1;
 
@@ -193,9 +197,10 @@ static uoff_t mbox_mail_get_physical_siz
 	}
 
 	/* verify that the calculated body size is correct */
-	body_size = istream_raw_mbox_get_body_size(stream, body_size);
-
-	data->physical_size = (body_offset - hdr_offset) + body_size;
+	body_size = istream_raw_mbox_get_body_size(mbox->mbox_stream,
+						   body_size);
+
+	data->physical_size = hdr_size.physical_size + body_size;
 	return data->physical_size;
 
 }


More information about the dovecot-cvs mailing list