dovecot-2.2: lib-storage: Don't fetch wanted_fields for messages...

dovecot at dovecot.org dovecot at dovecot.org
Tue Nov 25 00:56:57 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/2553f3aae9bb
changeset: 18106:2553f3aae9bb
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Nov 25 02:56:37 2014 +0200
description:
lib-storage: Don't fetch wanted_fields for messages that don't match the search query.
For example "doveadm fetch text subject foo" was opening all the mails, even
though only a few matched the subject (that was hopefully already in cache
file).

The behavior still isn't perfect though. The wanted_fields should probably
be split into search_wanted_fields and fetch_wanted_fields, but the current
behavior is likely good enough for now.

diffstat:

 src/lib-storage/index/index-mail.c   |  13 +++++++++----
 src/lib-storage/index/index-mail.h   |   1 +
 src/lib-storage/index/index-search.c |   8 ++++++++
 3 files changed, 18 insertions(+), 4 deletions(-)

diffs (74 lines):

diff -r 1d811ffd1832 -r 2553f3aae9bb src/lib-storage/index/index-mail.c
--- a/src/lib-storage/index/index-mail.c	Fri Nov 21 18:17:00 2014 +0900
+++ b/src/lib-storage/index/index-mail.c	Tue Nov 25 02:56:37 2014 +0200
@@ -1435,9 +1435,9 @@
 	mail->data.save_envelope = TRUE;
 }
 
-static void index_mail_update_access_parts(struct index_mail *mail)
+void index_mail_update_access_parts(struct mail *_mail)
 {
-	struct mail *_mail = &mail->mail.mail;
+	struct index_mail *mail = (struct index_mail *)_mail;
 	struct index_mail_data *data = &mail->data;
 	const struct mail_cache_field *cache_fields = mail->ibox->cache_fields;
 	struct mail_cache_view *cache_view = _mail->transaction->cache_view;
@@ -1569,7 +1569,12 @@
 		return;
 	}
 
-	index_mail_update_access_parts(mail);
+	if (!mail->search_mail)
+		index_mail_update_access_parts(_mail);
+	else {
+		/* searching code will call the index_mail_update_access_parts()
+		   after we know the mail is actually wanted to be fetched. */
+	}
 	mail->data.initialized = TRUE;
 }
 
@@ -1660,7 +1665,7 @@
 			mailbox_header_lookup_init(_mail->box,
 						   array_idx(&names, 0));
 	}
-	index_mail_update_access_parts(mail);
+	index_mail_update_access_parts(_mail);
 }
 
 void index_mail_set_uid_cache_updates(struct mail *_mail, bool set)
diff -r 1d811ffd1832 -r 2553f3aae9bb src/lib-storage/index/index-mail.h
--- a/src/lib-storage/index/index-mail.h	Fri Nov 21 18:17:00 2014 +0900
+++ b/src/lib-storage/index/index-mail.h	Tue Nov 25 02:56:37 2014 +0200
@@ -171,6 +171,7 @@
 void index_mail_add_temp_wanted_fields(struct mail *mail,
 				       enum mail_fetch_field fields,
 				       struct mailbox_header_lookup_ctx *headers);
+void index_mail_update_access_parts(struct mail *mail);
 void index_mail_close(struct mail *mail);
 void index_mail_close_streams(struct index_mail *mail);
 void index_mail_free(struct mail *mail);
diff -r 1d811ffd1832 -r 2553f3aae9bb src/lib-storage/index/index-search.c
--- a/src/lib-storage/index/index-search.c	Fri Nov 21 18:17:00 2014 +0900
+++ b/src/lib-storage/index/index-search.c	Tue Nov 25 02:56:37 2014 +0200
@@ -1550,6 +1550,13 @@
 		mail_search_args_reset(_ctx->args->args, FALSE);
 
 		if (match != 0) {
+			/* either matched or result is still unknown.
+			   anyway we're far enough now that we probably want
+			   to update the access_parts. the only problem here is
+			   if searching would want fewer access_parts than the
+			   fetching part, but that's probably not a big problem
+			   usually. */
+			index_mail_update_access_parts(mail);
 			ret = 1;
 			break;
 		}
@@ -1730,6 +1737,7 @@
 
 	mailp = array_idx(&ctx->mails, 0);
 	mail_set_seq(*mailp, seq);
+	index_mail_update_access_parts(*mailp);
 	*mail_r = *mailp;
 	return TRUE;
 }


More information about the dovecot-cvs mailing list