]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dsync: Give hints to lib-storage about what fields we're going to fetch.
authorTimo Sirainen <tss@iki.fi>
Sat, 16 Nov 2013 19:17:56 +0000 (21:17 +0200)
committerTimo Sirainen <tss@iki.fi>
Sat, 16 Nov 2013 19:17:56 +0000 (21:17 +0200)
src/doveadm/dsync/dsync-mail.c
src/doveadm/dsync/dsync-mail.h
src/doveadm/dsync/dsync-mailbox-export.c

index ebda61adf15aeb5988a0dbe91dbb8c1300996054..318435f45c530c01257c991e22bc6b50a03592c5 100644 (file)
@@ -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;
index 083a8ed8731b3e99ad3ddd211d7ec47634de1575..4339030590abfd811c0159cc8a215a8465213d15 100644 (file)
@@ -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);
index a62f41377064d6e07d7f1872cc67b34a000547a9..77c1aec35029d3ff87f787c78d0fd80cce6d99b7 100644 (file)
@@ -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);