changeset 7900:40863bb70e3c HEAD

mbox: Don't give "Can't find next message offset" warnings when (quota) plugin accesses the message being saved.
author Timo Sirainen <tss@iki.fi>
date Thu, 19 Jun 2008 08:14:46 +0300
parents 11727b49373e
children fbbb1cdb2fe9
files src/lib-storage/index/mbox/mbox-mail.c
diffstat 1 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/mbox-mail.c	Thu Jun 19 08:13:36 2008 +0300
+++ b/src/lib-storage/index/mbox/mbox-mail.c	Thu Jun 19 08:14:46 2008 +0300
@@ -174,12 +174,12 @@
 	const struct mail_index_header *hdr;
 	uint32_t seq;
 	int trailer_size;
-	bool ret;
+	int ret = 1;
 
 	hdr = mail_index_get_header(mail->trans->trans_view);
 	if (mail->mail.mail.seq > hdr->messages_count) {
 		/* we're appending a new message */
-		return FALSE;
+		return 0;
 	}
 
 	/* We can't really trust trans_view. The next message may already be
@@ -198,10 +198,10 @@
 		trailer_size = (mbox->storage->storage.flags &
 				MAIL_STORAGE_FLAG_SAVE_CRLF) != 0 ? 2 : 1;
 		*next_offset_r = hdr->sync_size - trailer_size;
-		ret = TRUE;
 	} else {
-		ret = mbox_file_lookup_offset(mbox, view, seq + 1,
-					      next_offset_r) > 0;
+		if (mbox_file_lookup_offset(mbox, view, seq + 1,
+					    next_offset_r) <= 0)
+			ret = -1;
 	}
 	mail_index_view_close(&view);
 	return ret;
@@ -234,7 +234,7 @@
 
 	/* use the next message's offset to avoid reading through the entire
 	   message body to find out its size */
-	if (mbox_mail_get_next_offset(mail, &next_offset))
+	if (mbox_mail_get_next_offset(mail, &next_offset) > 0)
 		body_size = next_offset - body_offset;
 	else
 		body_size = (uoff_t)-1;
@@ -255,20 +255,24 @@
 	struct mbox_mailbox *mbox = (struct mbox_mailbox *)mail->ibox;
 	struct istream *raw_stream;
 	uoff_t hdr_offset, next_offset;
+	int ret;
 
 	if (mbox_mail_seek(mail) < 0)
 		return -1;
 
-	if (!mbox_mail_get_next_offset(mail, &next_offset)) {
+	ret = mbox_mail_get_next_offset(mail, &next_offset);
+	if (ret < 0) {
 		if (mbox_mail_seek(mail) < 0)
 			return -1;
-		if (!mbox_mail_get_next_offset(mail, &next_offset)) {
+		ret = mbox_mail_get_next_offset(mail, &next_offset);
+		if (ret < 0) {
 			i_warning("mbox %s: Can't find next message offset "
 				  "for uid=%u",
 				  mbox->path, mail->mail.mail.uid);
-			next_offset = (uoff_t)-1;
 		}
 	}
+	if (ret <= 0)
+		next_offset = (uoff_t)-1;
 
 	raw_stream = mbox->mbox_stream;
 	hdr_offset = istream_raw_mbox_get_header_offset(raw_stream);