dovecot-2.2: dsync: Give hints to lib-storage about what fields ...

dovecot at dovecot.org dovecot at dovecot.org
Sat Nov 16 21:18:13 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/da32044d4fc8
changeset: 16963:da32044d4fc8
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Nov 16 21:17:56 2013 +0200
description:
dsync: Give hints to lib-storage about what fields we're going to fetch.

diffstat:

 src/doveadm/dsync/dsync-mail.c           |   6 ++++++
 src/doveadm/dsync/dsync-mail.h           |   4 ++++
 src/doveadm/dsync/dsync-mailbox-export.c |  10 ++++++++++
 3 files changed, 20 insertions(+), 0 deletions(-)

diffs (78 lines):

diff -r 0c9b17f7cadf -r da32044d4fc8 src/doveadm/dsync/dsync-mail.c
--- a/src/doveadm/dsync/dsync-mail.c	Sat Nov 16 20:10:27 2013 +0200
+++ b/src/doveadm/dsync/dsync-mail.c	Sat Nov 16 21:17:56 2013 +0200
@@ -18,6 +18,12 @@
 	"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 -r 0c9b17f7cadf -r da32044d4fc8 src/doveadm/dsync/dsync-mail.h
--- a/src/doveadm/dsync/dsync-mail.h	Sat Nov 16 20:10:27 2013 +0200
+++ b/src/doveadm/dsync/dsync-mail.h	Sat Nov 16 21:17:56 2013 +0200
@@ -4,6 +4,7 @@
 #include "mail-types.h"
 
 struct mail;
+struct mailbox;
 
 struct dsync_mail {
 	/* either GUID="" or uid=0 */
@@ -76,6 +77,9 @@
 	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 -r 0c9b17f7cadf -r da32044d4fc8 src/doveadm/dsync/dsync-mailbox-export.c
--- a/src/doveadm/dsync/dsync-mailbox-export.c	Sat Nov 16 20:10:27 2013 +0200
+++ b/src/doveadm/dsync/dsync-mailbox-export.c	Sat Nov 16 21:17:56 2013 +0200
@@ -24,6 +24,7 @@
 	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 @@
 	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 @@
 	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 @@
 
 	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);


More information about the dovecot-cvs mailing list