[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-storage.c, 1.164, 1.165 maildir-sync.c, 1.100, 1.101

tss at dovecot.org tss at dovecot.org
Tue Apr 17 15:41:32 EEST 2007


Update of /var/lib/cvs/dovecot/src/lib-storage/index/maildir
In directory talvi:/tmp/cvs-serv21471/index/maildir

Modified Files:
	maildir-storage.c maildir-sync.c 
Log Message:
Added sync_notify() callback to struct mail_storage. It's now called for
expunges and flag/keyword changes (except with cydir).



Index: maildir-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-storage.c,v
retrieving revision 1.164
retrieving revision 1.165
diff -u -d -r1.164 -r1.165
--- maildir-storage.c	11 Apr 2007 10:55:36 -0000	1.164
+++ maildir-storage.c	17 Apr 2007 12:41:28 -0000	1.165
@@ -1055,6 +1055,7 @@
 		maildir_storage_sync_init,
 		index_mailbox_sync_next,
 		index_mailbox_sync_deinit,
+		NULL,
 		maildir_notify_changes,
 		index_transaction_begin,
 		index_transaction_commit,

Index: maildir-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-sync.c,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -d -r1.100 -r1.101
--- maildir-sync.c	30 Mar 2007 12:44:03 -0000	1.100
+++ maildir-sync.c	17 Apr 2007 12:41:28 -0000	1.101
@@ -232,7 +232,7 @@
 	struct mail_index_transaction *trans;
 
 	ARRAY_DEFINE(sync_recs, struct mail_index_sync_rec);
-	uint32_t seq;
+	uint32_t seq, uid;
 	int dirty_state;
 };
 
@@ -397,9 +397,15 @@
 }
 
 static int maildir_expunge(struct maildir_mailbox *mbox, const char *path,
-			   void *context __attr_unused__)
+			   struct maildir_index_sync_context *ctx)
 {
+	struct mailbox *box = &mbox->ibox.box;
+
 	if (unlink(path) == 0) {
+		if (box->v.sync_notify != NULL) {
+			box->v.sync_notify(box, ctx->uid,
+					   MAILBOX_SYNC_TYPE_EXPUNGE);
+		}
 		mbox->dirty_cur_time = ioloop_time;
 		return 1;
 	}
@@ -414,9 +420,11 @@
 static int maildir_sync_flags(struct maildir_mailbox *mbox, const char *path,
 			      struct maildir_index_sync_context *ctx)
 {
+	struct mailbox *box = &mbox->ibox.box;
 	const struct mail_index_sync_rec *recs;
 	const char *dir, *fname, *newfname, *newpath;
 	enum mail_flags flags;
+	enum mailbox_sync_type sync_type = 0;
 	ARRAY_TYPE(keyword_indexes) keywords;
 	unsigned int i, count;
 	uint8_t flags8;
@@ -441,11 +449,13 @@
 		switch (recs[i].type) {
 		case MAIL_INDEX_SYNC_TYPE_FLAGS:
 			mail_index_sync_flags_apply(&recs[i], &flags8);
+			sync_type |= MAILBOX_SYNC_TYPE_FLAGS;
 			break;
 		case MAIL_INDEX_SYNC_TYPE_KEYWORD_ADD:
 		case MAIL_INDEX_SYNC_TYPE_KEYWORD_REMOVE:
 		case MAIL_INDEX_SYNC_TYPE_KEYWORD_RESET:
 			mail_index_sync_keywords_apply(&recs[i], &keywords);
+			sync_type |= MAILBOX_SYNC_TYPE_KEYWORDS;
 			break;
 		case MAIL_INDEX_SYNC_TYPE_APPEND:
 		case MAIL_INDEX_SYNC_TYPE_EXPUNGE:
@@ -453,12 +463,15 @@
 			break;
 		}
 	}
-
+	i_assert(sync_type != 0);
 
 	newfname = maildir_filename_set_flags(ctx->keywords_sync_ctx,
 					      fname, flags8, &keywords);
 	newpath = t_strconcat(dir, newfname, NULL);
 	if (rename(path, newpath) == 0) {
+		if (box->v.sync_notify != NULL)
+			box->v.sync_notify(box, ctx->uid, sync_type);
+
 		if ((flags8 & MAIL_INDEX_MAIL_FLAG_DIRTY) != 0)
 			ctx->dirty_state = -1;
 		mbox->dirty_cur_time = ioloop_time;
@@ -556,6 +569,7 @@
 		}
 
 		ctx->seq = seq;
+		ctx->uid = uid;
 		if (expunged) {
 			maildir_sync_check_timeouts(ctx->maildir_sync_ctx,
 						    TRUE);



More information about the dovecot-cvs mailing list