[dovecot-cvs] dovecot/src/lib-storage/list index-mailbox-list-sync.c, 1.4, 1.5 index-mailbox-list.c, 1.7, 1.8 index-mailbox-list.h, 1.1, 1.2

tss at dovecot.org tss at dovecot.org
Thu Mar 15 15:34:52 EET 2007


Update of /var/lib/cvs/dovecot/src/lib-storage/list
In directory talvi:/tmp/cvs-serv9898/lib-storage/list

Modified Files:
	index-mailbox-list-sync.c index-mailbox-list.c 
	index-mailbox-list.h 
Log Message:
Fixed desyncing problems with mail index and mailbox list index.



Index: index-mailbox-list-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/list/index-mailbox-list-sync.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- index-mailbox-list-sync.c	24 Jan 2007 12:49:20 -0000	1.4
+++ index-mailbox-list-sync.c	15 Mar 2007 13:34:50 -0000	1.5
@@ -176,7 +176,7 @@
 		return 0;
 	}
 
-	ret = mailbox_list_index_lookup(ilist->list_index, box->name, &uid);
+	ret = mailbox_list_index_lookup(ilist->list_sync_view, box->name, &uid);
 	if (ret <= 0)
 		return ret;
 
@@ -260,7 +260,8 @@
 	struct mailbox_list_index_sync_ctx *sync_ctx;
 	int ret;
 
-	ret = mailbox_list_index_lookup(ilist->list_index, box->name, uid_r);
+	ret = mailbox_list_index_lookup(ilist->list_sync_view,
+					box->name, uid_r);
 	if (ret > 0) {
 		/* we'll need the mailbox synced since we're updating its
 		   contents based on what it already contains */
@@ -279,7 +280,8 @@
 	if (mailbox_list_index_sync_commit(&sync_ctx) < 0)
 		return -1;
 
-	ret = mailbox_list_index_lookup(ilist->list_index, box->name, uid_r);
+	ret = mailbox_list_index_lookup(ilist->list_sync_view,
+					box->name, uid_r);
 	if (ret != 0)
 		return ret < 0 ? -1 : 0;
 

Index: index-mailbox-list.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/list/index-mailbox-list.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- index-mailbox-list.c	15 Mar 2007 02:00:26 -0000	1.7
+++ index-mailbox-list.c	15 Mar 2007 13:34:50 -0000	1.8
@@ -28,7 +28,7 @@
 	struct mail_index_view_sync_rec sync_rec;
 	int ret;
 
-	if (mail_index_view_sync_begin(ctx->view, MAIL_INDEX_SYNC_MASK_ALL,
+	if (mail_index_view_sync_begin(ctx->mail_view, MAIL_INDEX_SYNC_MASK_ALL,
 				       &sync_ctx) < 0) {
 		mailbox_list_set_internal_error(ctx->ctx.list);
 		return -1;
@@ -74,7 +74,7 @@
 
 	ctx->sync_stamp = st.st_mtime;
 
-	hdr = mail_index_get_header(ctx->view);
+	hdr = mail_index_get_header(ctx->mail_view);
 	return hdr->sync_stamp == ctx->sync_stamp;
 }
 
@@ -123,16 +123,18 @@
 	ctx->glob = imap_match_init(default_pool, mask, TRUE,
 				    list->hierarchy_sep);
 
-	ctx->view = mail_index_view_open(ilist->mail_index);
+	ctx->mail_view = mail_index_view_open(ilist->mail_index);
+	ctx->view = mailbox_list_index_view_init(ilist->list_index,
+						 ctx->mail_view);
 	if (index_mailbox_list_is_synced(ctx) > 0) {
 		/* synced, list from index */
 		mask_parse(list, mask, &prefix, &recurse_level);
 
 		ctx->info_pool =
 			pool_alloconly_create("mailbox name pool", 128);
-		ctx->iter_ctx =
-			mailbox_list_index_iterate_init(ilist->list_index,
-							prefix, recurse_level);
+		ctx->iter_ctx = mailbox_list_index_iterate_init(ctx->view,
+								prefix,
+								recurse_level);
 		ctx->recurse_level = recurse_level;
 		ctx->prefix = *prefix == '\0' ? i_strdup("") :
 			i_strdup_printf("%s%c", prefix, list->hierarchy_sep);
@@ -217,7 +219,7 @@
 	} while (imap_match(ctx->glob, ctx->info.name) != IMAP_MATCH_YES);
 
 	/* get the mailbox's flags */
-	if (mail_index_lookup_uid_range(ctx->view, iinfo.uid, iinfo.uid,
+	if (mail_index_lookup_uid_range(ctx->mail_view, iinfo.uid, iinfo.uid,
 					&seq, &seq) < 0)
 		return -1;
 	if (seq == 0) {
@@ -226,7 +228,7 @@
 		return -1;
 	}
 
-	if (mail_index_lookup(ctx->view, seq, &rec) < 0)
+	if (mail_index_lookup(ctx->mail_view, seq, &rec) < 0)
 		return -1;
 	ctx->info.flags = index_mailbox_list_index_flags_translate(rec->flags);
 
@@ -301,8 +303,10 @@
 		pool_unref(ctx->info_pool);
 	}
 
+	if (ctx->mail_view != NULL)
+		mail_index_view_close(&ctx->mail_view);
 	if (ctx->view != NULL)
-		mail_index_view_close(&ctx->view);
+		mailbox_list_index_view_deinit(&ctx->view);
 
 	if (ctx->sync_ctx != NULL) {
 		/* FIXME: single sync_stamp works only with maildir++ */
@@ -332,6 +336,7 @@
 	struct index_mailbox_list *ilist = INDEX_LIST_CONTEXT(list);
 
 	mailbox_list_index_free(&ilist->list_index);
+	mailbox_list_index_view_deinit(&ilist->list_sync_view);
 	mail_index_free(&ilist->mail_index);
 
 	ilist->super.deinit(list);
@@ -380,6 +385,8 @@
 		mailbox_list_index_free(&ilist->list_index);
 		return -1;
 	}
+	ilist->list_sync_view = mailbox_list_index_view_init(ilist->list_index,
+							     NULL);
 	return 0;
 }
 

Index: index-mailbox-list.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/list/index-mailbox-list.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- index-mailbox-list.h	25 Nov 2006 22:17:50 -0000	1.1
+++ index-mailbox-list.h	15 Mar 2007 13:34:50 -0000	1.2
@@ -15,6 +15,7 @@
 
 	struct mail_index *mail_index;
 	struct mailbox_list_index *list_index;
+	struct mailbox_list_index_view *list_sync_view;
 
 	uint32_t eid_messages, eid_unseen, eid_recent;
 	uint32_t eid_uid_validity, eid_uidnext;
@@ -29,7 +30,8 @@
 	struct mailbox_list_index_sync_ctx *sync_ctx;
 	struct mailbox_list_iterate_context *backend_ctx;
 
-	struct mail_index_view *view;
+	struct mailbox_list_index_view *view;
+	struct mail_index_view *mail_view;
 	struct mail_index_transaction *trans;
 
 	char *prefix;



More information about the dovecot-cvs mailing list