dovecot-2.2: dsync: Set wanted_fields/headers for the whole sear...

dovecot at dovecot.org dovecot at dovecot.org
Sun Nov 17 16:11:45 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/12b6698e91a9
changeset: 16973:12b6698e91a9
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Nov 17 16:11:31 2013 +0200
description:
dsync: Set wanted_fields/headers for the whole search request when possible.

diffstat:

 src/doveadm/dsync/dsync-mailbox-export.c |  13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diffs (39 lines):

diff -r ef649e2a980e -r 12b6698e91a9 src/doveadm/dsync/dsync-mailbox-export.c
--- a/src/doveadm/dsync/dsync-mailbox-export.c	Sun Nov 17 15:13:58 2013 +0200
+++ b/src/doveadm/dsync/dsync-mailbox-export.c	Sun Nov 17 16:11:31 2013 +0200
@@ -273,6 +273,8 @@
 	time_t save_timestamp;
 	int ret;
 
+	/* update wanted fields in case we didn't already set them for the
+	   search */
 	mail_add_temp_wanted_fields(mail, MAIL_FETCH_GUID |
 				    MAIL_FETCH_SAVE_DATE,
 				    exporter->wanted_headers);
@@ -338,6 +340,8 @@
 	struct mail_search_args *search_args;
 	struct mail_search_arg *sarg;
 	struct mail *mail;
+	enum mail_fetch_field wanted_fields = 0;
+	struct mailbox_header_lookup_ctx *wanted_headers = NULL;
 	int ret;
 
 	search_args = mail_search_build_init();
@@ -357,9 +361,16 @@
 					  (uint32_t)-1);
 	}
 
+	if (exporter->last_common_uid == 0) {
+		/* we're syncing all mails, so we can request the wanted
+		   fields for all the mails */
+		wanted_fields = MAIL_FETCH_GUID | MAIL_FETCH_SAVE_DATE;
+		wanted_headers = exporter->wanted_headers;
+	}
+
 	exporter->trans = mailbox_transaction_begin(exporter->box, 0);
 	search_ctx = mailbox_search_init(exporter->trans, search_args, NULL,
-					 0, NULL);
+					 wanted_fields, wanted_headers);
 	mail_search_args_unref(&search_args);
 
 	while (mailbox_search_next(search_ctx, &mail)) {


More information about the dovecot-cvs mailing list