dovecot-2.2: maildir: If istream_opened hook is set, don't retur...

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


details:   http://hg.dovecot.org/dovecot-2.2/rev/1adbd576f320
changeset: 17195:1adbd576f320
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Apr 04 00:14:42 2014 +0300
description:
maildir: If istream_opened hook is set, don't return stat()ed file size as physical size.
That's pretty much always wrong. The hook is set with e.g. zlib and
mail-filter and similar plugins that modify the mail stream.

diffstat:

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

diffs (28 lines):

diff -r 2338a2c96a22 -r 1adbd576f320 src/lib-storage/index/maildir/maildir-mail.c
--- a/src/lib-storage/index/maildir/maildir-mail.c	Fri Apr 04 00:13:35 2014 +0300
+++ b/src/lib-storage/index/maildir/maildir-mail.c	Fri Apr 04 00:14:42 2014 +0300
@@ -421,6 +421,8 @@
 	struct maildir_mailbox *mbox = (struct maildir_mailbox *)_mail->box;
 	struct index_mail_data *data = &mail->data;
 	struct stat st;
+	struct message_size hdr_size, body_size;
+	struct istream *input;
 	const char *path;
 	int ret;
 
@@ -448,7 +450,14 @@
 		return 0;
 	}
 
-	if (!_mail->saving) {
+	if (mail->mail.v.istream_opened != NULL) {
+		/* we can't use stat(), because this may be a mail that some
+		   plugin has changed (e.g. zlib). need to do it the slow
+		   way. */
+		if (mail_get_stream(_mail, &hdr_size, &body_size, &input) < 0)
+			return -1;
+		st.st_size = hdr_size.physical_size + body_size.physical_size;
+	} else if (!_mail->saving) {
 		ret = maildir_file_do(mbox, _mail->uid, do_stat, &st);
 		if (ret <= 0) {
 			if (ret == 0)


More information about the dovecot-cvs mailing list