static int
message_search_msg_real(struct message_search_context *ctx,
- struct istream *input, struct message_part *parts)
+ struct istream *input, struct message_part *parts,
+ const char **error_r)
{
const enum message_header_parser_flags hdr_parser_flags =
MESSAGE_HEADER_PARSER_FLAG_CLEAN_ONELINE;
/* normal exit */
ret = 0;
}
- if (message_parser_deinit(&parser_ctx, &new_parts) < 0) {
+ if (message_parser_deinit_from_parts(&parser_ctx, &new_parts, error_r) < 0) {
/* broken parts */
ret = -1;
}
}
int message_search_msg(struct message_search_context *ctx,
- struct istream *input, struct message_part *parts)
+ struct istream *input, struct message_part *parts,
+ const char **error_r)
{
+ char *error;
int ret;
T_BEGIN {
- ret = message_search_msg_real(ctx, input, parts);
+ ret = message_search_msg_real(ctx, input, parts, error_r);
+ error = i_strdup(*error_r);
} T_END;
+ *error_r = t_strdup(error);
+ i_free(error);
return ret;
}
/* Search a full message. Returns 1 if match was found, 0 if not,
-1 if error (if stream_error == 0, the parts contained broken data) */
int message_search_msg(struct message_search_context *ctx,
- struct istream *input, struct message_part *parts)
+ struct istream *input, struct message_part *parts,
+ const char **error_r)
ATTR_NULL(3);
#endif
struct search_body_context *ctx)
{
struct message_search_context *msg_search_ctx;
+ const char *error;
int ret;
switch (arg->type) {
}
i_stream_seek(ctx->input, 0);
- ret = message_search_msg(msg_search_ctx, ctx->input, ctx->part);
+ ret = message_search_msg(msg_search_ctx, ctx->input, ctx->part, &error);
if (ret < 0 && ctx->input->stream_errno == 0) {
/* try again without cached parts */
mail_set_cache_corrupted_reason(ctx->index_ctx->cur_mail,
- MAIL_FETCH_MESSAGE_PARTS,
- "Cached MIME parts don't match message during parsing in SEARCH");
+ MAIL_FETCH_MESSAGE_PARTS, t_strdup_printf(
+ "Cached MIME parts don't match message during parsing in SEARCH: %s", error));
i_stream_seek(ctx->input, 0);
- ret = message_search_msg(msg_search_ctx, ctx->input, NULL);
+ ret = message_search_msg(msg_search_ctx, ctx->input, NULL, &error);
i_assert(ret >= 0 || ctx->input->stream_errno != 0);
}
if (ctx->input->stream_errno != 0) {