item->u.mail.input = mail->input;
i_stream_ref(mail->input);
}
+ item->u.mail.input_mail = mail->input_mail;
+ item->u.mail.input_mail_uid = mail->input_mail_uid;
}
static enum dsync_ibc_recv_ret
/* Input stream containing the message text, or NULL if all instances
of the message were already expunged from this mailbox. */
struct istream *input;
+
+ /* If non-NULL, we're syncing within the dsync process using ibc-pipe.
+ This mail can be used to mailbox_copy() the mail. */
+ struct mail *input_mail;
+ /* Verify that this equals to input_mail->uid */
+ uint32_t input_mail_uid;
};
struct dsync_mail_request {
return -1;
}
+ dmail->input_mail = mail;
+ dmail->input_mail_uid = mail->uid;
if (mail_get_stream(mail, NULL, NULL, &dmail->input) < 0)
return dsync_mail_error(exporter, mail, "body");
if (save_ctx == NULL)
save_ctx = dsync_mailbox_save_init(importer, mail, newmail);
}
+ if (ret <= 0 && mail->input_mail != NULL) {
+ /* copy using the source mail */
+ i_assert(mail->input_mail->uid == mail->input_mail_uid);
+ if (mailbox_copy(&save_ctx, mail->input_mail) == 0)
+ ret = 1;
+ else {
+ ret = -1;
+ save_ctx = dsync_mailbox_save_init(importer, mail, newmail);
+ }
+
+ }
if (ret > 0) {
array_append(&importer->wanted_uids, &newmail->uid, 1);
return;