dovecot-2.2: lib-storage: When trying to get body size quickly, ...

dovecot at dovecot.org dovecot at dovecot.org
Thu Apr 3 21:14:56 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/2338a2c96a22
changeset: 17194:2338a2c96a22
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Apr 04 00:13:35 2014 +0300
description:
lib-storage: When trying to get body size quickly, make sure we don't end up reading the mail body.

diffstat:

 src/lib-storage/index/index-mail.c |  15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diffs (25 lines):

diff -r 0ca197d2da42 -r 2338a2c96a22 src/lib-storage/index/index-mail.c
--- a/src/lib-storage/index/index-mail.c	Thu Apr 03 23:38:17 2014 +0300
+++ b/src/lib-storage/index/index-mail.c	Fri Apr 04 00:13:35 2014 +0300
@@ -435,10 +435,17 @@
 		return;
 
 	if (!data->body_size_set) {
-		if (mail_get_physical_size(&mail->mail.mail, &tmp) < 0)
-			return;
-		/* we should have everything now. try again. */
-		(void)index_mail_get_cached_virtual_size(mail, &tmp);
+		enum mail_lookup_abort old_abort = mail->mail.mail.lookup_abort;
+
+		/* get the physical size, but not if it requires reading
+		   through the whole message */
+		if (mail->mail.mail.lookup_abort < MAIL_LOOKUP_ABORT_READ_MAIL)
+			mail->mail.mail.lookup_abort = MAIL_LOOKUP_ABORT_READ_MAIL;
+		if (mail_get_physical_size(&mail->mail.mail, &tmp) == 0) {
+			/* we should have everything now. try again. */
+			(void)index_mail_get_cached_virtual_size(mail, &tmp);
+		}
+		mail->mail.mail.lookup_abort = old_abort;
 	}
 }
 


More information about the dovecot-cvs mailing list