changeset 8558:94e0fda6802e HEAD

mail_set_seq(): Don't open input stream immediately if message hasn't been saved yet.
author Timo Sirainen <tss@iki.fi>
date Tue, 16 Dec 2008 06:08:26 +0200
parents 076ccdcbbeb2
children b0bc4519332f
files src/lib-storage/index/index-mail.c
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/index-mail.c	Tue Dec 16 05:30:31 2008 +0200
+++ b/src/lib-storage/index/index-mail.c	Tue Dec 16 06:08:26 2008 +0200
@@ -1181,7 +1181,8 @@
 	struct index_mail *mail = (struct index_mail *)_mail;
 	struct index_mail_data *data = &mail->data;
 	struct mail_cache_field *cache_fields = mail->ibox->cache_fields;
-        struct mail_cache_view *cache_view = mail->trans->cache_view;
+	struct mail_cache_view *cache_view = mail->trans->cache_view;
+	const struct mail_index_header *hdr;
 	struct istream *input;
 
 	if (data->seq == seq)
@@ -1287,7 +1288,11 @@
 		if ((mail->wanted_fields & MAIL_FETCH_STREAM_BODY) != 0)
 			data->access_part |= READ_BODY;
 
-		(void)mail_get_stream(_mail, NULL, NULL, &input);
+		/* open the stream only if we didn't get here from
+		   mailbox_save_init() */
+		hdr = mail_index_get_header(mail->ibox->view);
+		if (_mail->uid != 0 && _mail->uid < hdr->next_uid)
+			(void)mail_get_stream(_mail, NULL, NULL, &input);
 	}
 }