]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mail_set_seq(): Don't open input stream immediately if message hasn't been saved...
authorTimo Sirainen <tss@iki.fi>
Tue, 16 Dec 2008 04:08:26 +0000 (06:08 +0200)
committerTimo Sirainen <tss@iki.fi>
Tue, 16 Dec 2008 04:08:26 +0000 (06:08 +0200)
--HG--
branch : HEAD

src/lib-storage/index/index-mail.c

index 65bac036ae869903e20e1fa4a386e2f8fe7a7f20..17fccbe31f5e5b802d42bd6d2a2ac8bf57399abf 100644 (file)
@@ -1181,7 +1181,8 @@ void index_mail_set_seq(struct mail *_mail, uint32_t seq)
        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 @@ void index_mail_set_seq(struct mail *_mail, uint32_t seq)
                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);
        }
 }