dovecot-2.2: lib-storage: When updating flags in private index a...

dovecot at dovecot.org dovecot at dovecot.org
Wed Nov 28 07:25:28 EET 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/9107b794b7ad
changeset: 15428:9107b794b7ad
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Nov 28 07:24:01 2012 +0200
description:
lib-storage: When updating flags in private index and nothing changes, don't increase modseq.

diffstat:

 src/lib-storage/index/index-mail.c |  31 +++++++++++++++++++++++++++++--
 1 files changed, 29 insertions(+), 2 deletions(-)

diffs (48 lines):

diff -r 3c5f674285a8 -r 9107b794b7ad src/lib-storage/index/index-mail.c
--- a/src/lib-storage/index/index-mail.c	Wed Nov 28 06:51:16 2012 +0200
+++ b/src/lib-storage/index/index-mail.c	Wed Nov 28 07:24:01 2012 +0200
@@ -1655,6 +1655,34 @@
 	}
 }
 
+static bool
+index_mail_update_pvt_flags(struct mail *_mail, enum modify_type modify_type,
+			    enum mail_flags pvt_flags)
+{
+	struct mail_private *mail = (struct mail_private *)_mail;
+	const struct mail_index_record *rec;
+	enum mail_flags old_pvt_flags;
+
+	if (!index_mail_get_pvt(_mail))
+		return FALSE;
+	if (pvt_flags == 0 && modify_type != MODIFY_REPLACE)
+		return FALSE;
+
+	/* see if the flags actually change anything */
+	rec = mail_index_lookup(_mail->transaction->view_pvt, mail->seq_pvt);
+	old_pvt_flags = rec->flags & mailbox_get_private_flags_mask(_mail->box);
+
+	switch (modify_type) {
+	case MODIFY_ADD:
+		return (old_pvt_flags & pvt_flags) != pvt_flags;
+	case MODIFY_REPLACE:
+		return old_pvt_flags != pvt_flags;
+	case MODIFY_REMOVE:
+		return (old_pvt_flags & pvt_flags) != 0;
+	}
+	i_unreached();
+}
+
 void index_mail_update_flags(struct mail *_mail, enum modify_type modify_type,
 			     enum mail_flags flags)
 {
@@ -1672,8 +1700,7 @@
 		pvt_flags_mask = mailbox_get_private_flags_mask(_mail->box);
 		pvt_flags = flags & pvt_flags_mask;
 		flags &= ~pvt_flags_mask;
-		if (index_mail_get_pvt(_mail) &&
-		    (pvt_flags != 0 || modify_type == MODIFY_REPLACE)) {
+		if (index_mail_update_pvt_flags(_mail, modify_type, pvt_flags)) {
 			mail_index_update_flags(_mail->transaction->itrans_pvt,
 						mail->seq_pvt,
 						modify_type, pvt_flags);


More information about the dovecot-cvs mailing list