if (get_body && !mail->body_fetched &&
mail->imail.data.stream != NULL) {
/* we've fetched the header, but we need the body now too */
- i_stream_unref(&mail->imail.data.stream);
+ index_mail_close_streams(&mail->imail);
}
if (data->stream == NULL) {
while (mail->fetch_count > 0)
imapc_storage_run(mbox->storage);
+ index_mail_close(_mail);
+
if (mail->body_fetched) {
imapc_mail_cache_free(cache);
cache->uid = _mail->uid;
}
if (mail->body != NULL)
buffer_free(&mail->body);
-
- index_mail_close(_mail);
}
struct mail_vfuncs imapc_mail_vfuncs = {
}
}
-void index_mail_close(struct mail *_mail)
+void index_mail_close_streams(struct index_mail *mail)
{
- struct index_mail *mail = (struct index_mail *)_mail;
struct message_part *parts;
- /* If uid == 0 but seq != 0, we came here from saving a (non-mbox)
- message. If that happens, don't bother checking if anything should
- be cached since it was already checked. Also by now the transaction
- may have already been rollbacked and seq point to a nonexistent
- message. */
- if (mail->mail.mail.uid != 0) {
- index_mail_cache_sizes(mail);
- index_mail_cache_dates(mail);
- }
-
if (mail->data.parser_ctx != NULL) {
if (message_parser_deinit(&mail->data.parser_ctx, &parts) < 0) {
- mail_set_cache_corrupted(_mail,
+ mail_set_cache_corrupted(&mail->mail.mail,
MAIL_FETCH_MESSAGE_PARTS);
}
}
}
}
+void index_mail_close(struct mail *_mail)
+{
+ struct index_mail *mail = (struct index_mail *)_mail;
+
+ /* If uid == 0 but seq != 0, we came here from saving a (non-mbox)
+ message. If that happens, don't bother checking if anything should
+ be cached since it was already checked. Also by now the transaction
+ may have already been rollbacked and seq point to a nonexistent
+ message. */
+ if (mail->mail.mail.uid != 0) {
+ index_mail_cache_sizes(mail);
+ index_mail_cache_dates(mail);
+ }
+
+ index_mail_close_streams(mail);
+}
+
static void index_mail_reset(struct index_mail *mail)
{
struct index_mail_data *data = &mail->data;
void index_mail_set_uid_cache_updates(struct mail *mail, bool set);
bool index_mail_prefetch(struct mail *mail);
void index_mail_close(struct mail *mail);
+void index_mail_close_streams(struct index_mail *mail);
void index_mail_free(struct mail *mail);
bool index_mail_want_parse_headers(struct index_mail *mail);