[dovecot-cvs] dovecot/src/lib-index mail-index.c,1.94,1.95 mail-index.h,1.85,1.86

cras at procontrol.fi cras at procontrol.fi
Mon Aug 11 03:56:25 EEST 2003


Update of /home/cvs/dovecot/src/lib-index
In directory danu:/tmp/cvs-serv17929/lib-index

Modified Files:
	mail-index.c mail-index.h 
Log Message:
Maildir syncing works now without requiring base filenames to be in index
cache file. Also message flag updates with +FLAGS and -FLAGS works correctly
now if another client had just changed it's flags.



Index: mail-index.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -d -r1.94 -r1.95
--- mail-index.c	6 Aug 2003 20:15:31 -0000	1.94
+++ mail-index.c	10 Aug 2003 23:56:22 -0000	1.95
@@ -586,19 +586,36 @@
 }
 
 int mail_index_update_flags(struct mail_index *index,
-			    struct mail_index_record *rec,
-			    unsigned int seq, enum mail_flags flags,
+			    struct mail_index_record *rec, unsigned int seq,
+			    enum modify_type modify_type, enum mail_flags flags,
 			    int external_change)
 {
+	enum mail_flags new_flags;
+
 	i_assert(index->lock_type == MAIL_LOCK_EXCLUSIVE);
 	i_assert(seq != 0);
 
-	if (flags == rec->msg_flags)
+	switch (modify_type) {
+	case MODIFY_ADD:
+		new_flags = rec->msg_flags | flags;
+		break;
+	case MODIFY_REMOVE:
+		new_flags = rec->msg_flags & ~flags;
+		break;
+	case MODIFY_REPLACE:
+		new_flags = flags;
+		break;
+	default:
+		new_flags = 0;
+		i_unreached();
+	}
+
+	if (new_flags == rec->msg_flags)
 		return TRUE; /* no changes */
 
-        mail_index_mark_flag_changes(index, rec, rec->msg_flags, flags);
+        mail_index_mark_flag_changes(index, rec, rec->msg_flags, new_flags);
 
-	rec->msg_flags = flags;
+	rec->msg_flags = new_flags;
 	return index->modifylog == NULL ? TRUE :
 		mail_modifylog_add_flags(index->modifylog, seq,
 					 rec->uid, external_change);

Index: mail-index.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.h,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -d -r1.85 -r1.86
--- mail-index.h	6 Aug 2003 20:15:31 -0000	1.85
+++ mail-index.h	10 Aug 2003 23:56:22 -0000	1.86
@@ -246,11 +246,10 @@
 		       int external_change);
 
 	/* Update mail flags. The index must be exclusively locked before
-	   calling this function. This shouldn't be called in the middle of
-	   update_begin() as it may modify location field. */
+	   calling this function. */
 	int (*update_flags)(struct mail_index *index,
-			    struct mail_index_record *rec,
-			    unsigned int seq, enum mail_flags flags,
+			    struct mail_index_record *rec, unsigned int seq,
+			    enum modify_type modify_type, enum mail_flags flags,
 			    int external_change);
 
 	/* Append a new record to index. The index must be exclusively
@@ -382,8 +381,8 @@
 		       unsigned int first_seq, unsigned int last_seq,
 		       int external_change);
 int mail_index_update_flags(struct mail_index *index,
-			    struct mail_index_record *rec,
-			    unsigned int seq, enum mail_flags flags,
+			    struct mail_index_record *rec, unsigned int seq,
+			    enum modify_type modify_type, enum mail_flags flags,
 			    int external_change);
 struct mail_index_record *mail_index_append(struct mail_index *index);
 enum mail_index_error mail_index_get_last_error(struct mail_index *index);



More information about the dovecot-cvs mailing list