T_BEGIN {
index_mail_parse_header_finish(mail);
} T_END;
- data->save_bodystructure_header = FALSE;
+ if (data->save_bodystructure_header) {
+ i_assert(!data->save_bodystructure_body ||
+ data->parser_ctx != NULL);
+ data->save_bodystructure_header = FALSE;
+ }
return;
}
mail);
} else {
/* just read the header */
+ i_assert(!data->save_bodystructure_body ||
+ data->parser_ctx != NULL);
message_parse_header(data->stream, &data->hdr_size,
hdr_parser_flags,
index_mail_parse_header_cb, mail);
if (parser_input->stream_errno == 0 ||
parser_input->stream_errno == EPIPE) {
/* EPIPE = input already closed. allow the caller to
- decide if that is an error or not. */
+ decide if that is an error or not. (for example we
+ could be coming here from IMAP APPEND when IMAP
+ client has closed the connection too early. we
+ don't want to log an error in that case.) */
i_assert(!success ||
(i_stream_read(parser_input) == -1 &&
!i_stream_have_bytes_left(parser_input)));
}
mail->data.parts = NULL;
mail->data.parsed_bodystructure = FALSE;
+ if (mail->data.save_bodystructure_body)
+ mail->data.save_bodystructure_header = TRUE;
return -1;
}
+ if (mail->data.save_bodystructure_body) {
+ mail->data.parsed_bodystructure = TRUE;
+ mail->data.save_bodystructure_header = FALSE;
+ mail->data.save_bodystructure_body = FALSE;
+ i_assert(mail->data.parts != NULL);
+ }
if (mail->data.no_caching) {
/* if we're here because we aborted parsing, don't get any
ret = index_mail_stream_check_failure(mail);
if (index_mail_parse_body_finish(mail, field, TRUE) < 0)
ret = -1;
- if (ret == 0 && data->save_bodystructure_body) {
- data->save_bodystructure_body = FALSE;
- data->parsed_bodystructure = TRUE;
- i_assert(data->parts != NULL);
- }
i_stream_seek(data->stream, old_offset);
return ret;
data->save_bodystructure_header = TRUE;
data->save_bodystructure_body = TRUE;
(void)get_cached_parts(mail);
- if (index_mail_parse_headers(mail, NULL) < 0)
+ if (index_mail_parse_headers(mail, NULL) < 0) {
+ data->save_bodystructure_header = TRUE;
return -1;
+ }
+ i_assert(data->parser_ctx != NULL);
}
if (index_mail_parse_body(mail, field) < 0)
MAIL_FETCH_MESSAGE_PARTS);
}
mail->data.parser_input = NULL;
+ if (mail->data.save_bodystructure_body)
+ mail->data.save_bodystructure_header = TRUE;
}
if (data->filter_stream != NULL)
i_stream_unref(&data->filter_stream);
mail->data.save_date = ioloop_time;
}
- if (index_mail_parse_body_finish(mail, 0, success) == 0) {
- mail->data.save_bodystructure_body = FALSE;
- mail->data.parsed_bodystructure = TRUE;
- i_assert(mail->data.parts != NULL);
- }
+ (void)index_mail_parse_body_finish(mail, 0, success);
}
static void index_mail_drop_recent_flag(struct mail *mail)