dovecot-2.1: mbox: Fixed fetching last message from compressed m...

dovecot at dovecot.org dovecot at dovecot.org
Mon Sep 12 14:28:21 EEST 2011


details:   http://hg.dovecot.org/dovecot-2.1/rev/ea8f667ac6ef
changeset: 13448:ea8f667ac6ef
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Sep 12 14:27:46 2011 +0300
description:
mbox: Fixed fetching last message from compressed mboxes.

diffstat:

 src/lib-storage/index/mbox/mbox-mail.c |  14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diffs (28 lines):

diff -r 1a39f7648c9d -r ea8f667ac6ef src/lib-storage/index/mbox/mbox-mail.c
--- a/src/lib-storage/index/mbox/mbox-mail.c	Mon Sep 12 14:01:36 2011 +0300
+++ b/src/lib-storage/index/mbox/mbox-mail.c	Mon Sep 12 14:27:46 2011 +0300
@@ -259,15 +259,19 @@
 	if (!mail_index_lookup_seq(view, mail->mail.mail.uid, &seq))
 		i_panic("Message unexpectedly expunged from index");
 
-	if (seq == hdr->messages_count) {
+	if (seq < hdr->messages_count) {
+		if (mbox_file_lookup_offset(mbox, view, seq + 1,
+					    next_offset_r) <= 0)
+			ret = -1;
+	} else if (mail->mail.mail.box->input != NULL) {
+		/* opened the mailbox as input stream. we can't trust the
+		   sync_size, since it's wrong with compressed mailboxes */
+		ret = 0;
+	} else {
 		/* last message, use the synced mbox size */
 		trailer_size =
 			mbox->storage->storage.set->mail_save_crlf ? 2 : 1;
 		*next_offset_r = mbox->mbox_hdr.sync_size - trailer_size;
-	} else {
-		if (mbox_file_lookup_offset(mbox, view, seq + 1,
-					    next_offset_r) <= 0)
-			ret = -1;
 	}
 	mail_index_view_close(&view);
 	return ret;


More information about the dovecot-cvs mailing list