# HG changeset patch # User Timo Sirainen # Date 1103136486 -7200 # Node ID 32cc9186d8ebf4280a7aac1093a9a5ec00800585 # Parent 7c4238c78aeea6e18dc06e162beffaa97e67427d If we want MD5 sums in indexes, mail saving should also add them. diff -r 7c4238c78aee -r 32cc9186d8eb src/lib-storage/index/mbox/mbox-save.c --- a/src/lib-storage/index/mbox/mbox-save.c Wed Dec 15 20:43:40 2004 +0200 +++ b/src/lib-storage/index/mbox/mbox-save.c Wed Dec 15 20:48:06 2004 +0200 @@ -14,6 +14,7 @@ #include "mbox-file.h" #include "mbox-from.h" #include "mbox-lock.h" +#include "mbox-md5.h" #include "mbox-sync-private.h" #include @@ -41,6 +42,7 @@ struct index_mail mail; const struct mail_full_flags *flags; + struct mbox_md5_context *mbox_md5_ctx; unsigned int synced:1; unsigned int failed:1; @@ -276,10 +278,13 @@ } static void save_header_callback(struct message_header_line *hdr, - int *matched __attr_unused__, void *context) + int *matched, void *context) { struct mbox_save_context *ctx = context; + if (!*matched && ctx->ibox->mbox_save_md5 && hdr != NULL) + mbox_md5_continue(ctx->mbox_md5_ctx, hdr); + if ((hdr == NULL && ctx->eoh_input_offset == (uoff_t)-1) || (hdr != NULL && hdr->eoh)) ctx->eoh_input_offset = ctx->input->v_offset; @@ -371,6 +376,8 @@ ctx->body_output = getenv("MAIL_SAVE_CRLF") != NULL ? o_stream_create_crlf(default_pool, ctx->output) : o_stream_create_lf(default_pool, ctx->output); + if (ctx->ibox->mbox_save_md5) + ctx->mbox_md5_ctx = mbox_md5_init(); } return &ctx->ctx; @@ -429,6 +436,15 @@ } } + if (ctx->ibox->mbox_save_md5) { + unsigned char hdr_md5_sum[16]; + + mbox_md5_finish(ctx->mbox_md5_ctx, hdr_md5_sum); + mail_index_update_ext(ctx->trans, ctx->seq, + ctx->ibox->md5hdr_ext_idx, + hdr_md5_sum, NULL); + } + /* append our own headers and ending empty line */ ctx->extra_hdr_offset = ctx->output->offset; if (o_stream_send(ctx->output, str_data(ctx->headers),