ctx->ctx.output = dbox_output;
}
-void dbox_save_write_metadata(struct mail_save_context *ctx,
- struct ostream *output,
+void dbox_save_write_metadata(struct mail_save_context *_ctx,
+ struct ostream *output, uoff_t output_msg_size,
const char *orig_mailbox_name,
uint8_t guid_128[MAIL_GUID_128_SIZE])
{
+ struct dbox_save_context *ctx = (struct dbox_save_context *)_ctx;
struct dbox_metadata_header metadata_hdr;
const char *guid;
string_t *str;
o_stream_send(output, &metadata_hdr, sizeof(metadata_hdr));
str = t_str_new(256);
- if (ctx->saved_physical_size != 0) {
+ if (output_msg_size != ctx->input->v_offset) {
+ /* a plugin changed the data written to disk, so the
+ "message size" dbox header doesn't contain the actual
+ "physical" message size. we need to save it as a
+ separate metadata header. */
str_printfa(str, "%c%llx\n", DBOX_METADATA_PHYSICAL_SIZE,
- (unsigned long long)ctx->saved_physical_size);
+ (unsigned long long)ctx->input->v_offset);
}
str_printfa(str, "%c%lx\n", DBOX_METADATA_RECEIVED_TIME,
- (unsigned long)ctx->received_date);
- if (mail_get_virtual_size(ctx->dest_mail, &vsize) < 0)
+ (unsigned long)_ctx->received_date);
+ if (mail_get_virtual_size(_ctx->dest_mail, &vsize) < 0)
i_unreached();
str_printfa(str, "%c%llx\n", DBOX_METADATA_VIRTUAL_SIZE,
(unsigned long long)vsize);
- if (ctx->pop3_uidl != NULL) {
+ if (_ctx->pop3_uidl != NULL) {
str_printfa(str, "%c%s\n", DBOX_METADATA_POP3_UIDL,
- ctx->pop3_uidl);
+ _ctx->pop3_uidl);
}
- guid = ctx->guid;
+ guid = _ctx->guid;
if (guid != NULL)
mail_generate_guid_128_hash(guid, guid_128);
else {
mail->append_offset - mail->file_append->file->msg_header_size;
dbox_save_write_metadata(&ctx->ctx.ctx, ctx->ctx.dbox_output,
- ctx->mbox->box.name, guid_128);
+ message_size, ctx->mbox->box.name, guid_128);
/* save the 128bit GUID to index so if the map index gets corrupted
we can still find the message */
mail_index_update_ext(ctx->ctx.trans, ctx->ctx.seq,
message_size = ctx->dbox_output->offset -
file->msg_header_size - file->file_header_size;
- dbox_save_write_metadata(&ctx->ctx, ctx->dbox_output, NULL, guid_128);
+ dbox_save_write_metadata(&ctx->ctx, ctx->dbox_output,
+ message_size, NULL, guid_128);
dbox_msg_header_fill(&dbox_msg_hdr, message_size);
if (o_stream_pwrite(ctx->dbox_output, &dbox_msg_hdr,
sizeof(dbox_msg_hdr),