# HG changeset patch # User Timo Sirainen # Date 1487011576 -7200 # Node ID 0a4e672c70a104cb1b907dab7f2685816470aa07 # Parent 207a5e4b7a7f81be6c6d9af11faad1b4cb649026 lib-lda: Code cleanup - mail_deliver_open_mail() now uses uid parameter diff -r 207a5e4b7a7f -r 0a4e672c70a1 src/lib-lda/mail-deliver.c --- a/src/lib-lda/mail-deliver.c Mon Feb 13 20:44:31 2017 +0200 +++ b/src/lib-lda/mail-deliver.c Mon Feb 13 20:46:16 2017 +0200 @@ -276,27 +276,22 @@ } static struct mail * -mail_deliver_open_mail(struct mailbox *box, - const struct mail_transaction_commit_changes *changes, +mail_deliver_open_mail(struct mailbox *box, uint32_t uid, enum mail_fetch_field wanted_fields, struct mailbox_transaction_context **trans_r) { struct mailbox_transaction_context *t; struct mail *mail; - const struct seq_range *range; *trans_r = NULL; if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FAST) < 0) return NULL; - range = array_idx(&changes->saved_uids, 0); - i_assert(range[0].seq1 == range[0].seq2); - t = mailbox_transaction_begin(box, 0); mail = mail_alloc(t, wanted_fields, NULL); - if (!mail_set_uid(mail, range[0].seq1)) { + if (!mail_set_uid(mail, uid)) { mail_free(&mail); mailbox_transaction_rollback(&t); } @@ -383,7 +378,11 @@ /* copying needs the message body. with maildir we also need to get the GUID in case the message gets expunged */ - ctx->dest_mail = mail_deliver_open_mail(box, &changes, + i_assert(array_count(&changes.saved_uids) == 1); + const struct seq_range *range = + array_idx(&changes.saved_uids, 0); + i_assert(range->seq1 == range->seq2); + ctx->dest_mail = mail_deliver_open_mail(box, range->seq1, MAIL_FETCH_STREAM_BODY | MAIL_FETCH_GUID, &t); if (mail_get_special(ctx->dest_mail, MAIL_FETCH_GUID, &guid) < 0) { mail_free(&ctx->dest_mail);