From: Timo Sirainen Date: Sat, 16 Nov 2013 19:17:56 +0000 (+0200) Subject: dsync: Give hints to lib-storage about what fields we're going to fetch. X-Git-Tag: 2.2.8~24 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f97c983e7a742e1d54ec60e502093abbb3ad2907;p=thirdparty%2Fdovecot%2Fcore.git dsync: Give hints to lib-storage about what fields we're going to fetch. --- diff --git a/src/doveadm/dsync/dsync-mail.c b/src/doveadm/dsync/dsync-mail.c index ebda61adf1..318435f45c 100644 --- a/src/doveadm/dsync/dsync-mail.c +++ b/src/doveadm/dsync/dsync-mail.c @@ -18,6 +18,12 @@ static const char *hashed_headers[] = { "Date", "Message-ID", NULL }; +struct mailbox_header_lookup_ctx * +dsync_mail_get_hash_headers(struct mailbox *box) +{ + return mailbox_header_lookup_init(box, hashed_headers); +} + int dsync_mail_get_hdr_hash(struct mail *mail, const char **hdr_hash_r) { struct istream *hdr_input, *input; diff --git a/src/doveadm/dsync/dsync-mail.h b/src/doveadm/dsync/dsync-mail.h index 083a8ed873..4339030590 100644 --- a/src/doveadm/dsync/dsync-mail.h +++ b/src/doveadm/dsync/dsync-mail.h @@ -4,6 +4,7 @@ #include "mail-types.h" struct mail; +struct mailbox; struct dsync_mail { /* either GUID="" or uid=0 */ @@ -76,6 +77,9 @@ struct dsync_mail_change { ARRAY_TYPE(const_string) keyword_changes; }; +struct mailbox_header_lookup_ctx * +dsync_mail_get_hash_headers(struct mailbox *box); + int dsync_mail_get_hdr_hash(struct mail *mail, const char **hdr_hash_r); int dsync_mail_fill(struct mail *mail, struct dsync_mail *dmail_r, const char **error_field_r); diff --git a/src/doveadm/dsync/dsync-mailbox-export.c b/src/doveadm/dsync/dsync-mailbox-export.c index a62f413770..77c1aec350 100644 --- a/src/doveadm/dsync/dsync-mailbox-export.c +++ b/src/doveadm/dsync/dsync-mailbox-export.c @@ -24,6 +24,7 @@ struct dsync_mailbox_exporter { struct dsync_transaction_log_scan *log_scan; uint32_t last_common_uid; + struct mailbox_header_lookup_ctx *wanted_headers; struct mailbox_transaction_context *trans; struct mail_search_context *search_ctx; unsigned int search_pos, search_count; @@ -272,6 +273,10 @@ search_add_save(struct dsync_mailbox_exporter *exporter, struct mail *mail) time_t save_timestamp; int ret; + mail_add_temp_wanted_fields(mail, MAIL_FETCH_GUID | + MAIL_FETCH_SAVE_DATE, + exporter->wanted_headers); + /* If message is already expunged here, just skip it */ if ((ret = exporter_get_guids(exporter, mail, &guid, &hdr_hash)) <= 0) return ret; @@ -468,6 +473,9 @@ dsync_mailbox_export_init(struct mailbox *box, p_array_init(&exporter->expunged_seqs, pool, 16); p_array_init(&exporter->expunged_guids, pool, 16); + if (!exporter->mails_have_guids) + exporter->wanted_headers = dsync_mail_get_hash_headers(box); + /* first scan transaction log and save any expunges and flag changes */ dsync_mailbox_export_log_scan(exporter, log_scan); /* get saves and also find GUIDs for flag changes */ @@ -843,6 +851,8 @@ int dsync_mailbox_export_deinit(struct dsync_mailbox_exporter **_exporter, dsync_mailbox_export_body_search_deinit(exporter); (void)mailbox_transaction_commit(&exporter->trans); + if (exporter->wanted_headers != NULL) + mailbox_header_lookup_unref(&exporter->wanted_headers); if (exporter->attr.value_stream != NULL) i_stream_unref(&exporter->attr.value_stream);