dovecot-2.1: imapc: When doing a LIST, delete any extra local ma...

dovecot at dovecot.org dovecot at dovecot.org
Fri Nov 4 21:10:59 EET 2011


details:   http://hg.dovecot.org/dovecot-2.1/rev/0103b917fa0c
changeset: 13653:0103b917fa0c
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Nov 04 21:21:11 2011 +0200
description:
imapc: When doing a LIST, delete any extra local mailbox (index) directories.

diffstat:

 src/lib-storage/index/imapc/imapc-list.c |  27 ++++++++++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletions(-)

diffs (45 lines):

diff -r 7e1981ecbe40 -r 0103b917fa0c src/lib-storage/index/imapc/imapc-list.c
--- a/src/lib-storage/index/imapc/imapc-list.c	Fri Nov 04 21:20:19 2011 +0200
+++ b/src/lib-storage/index/imapc/imapc-list.c	Fri Nov 04 21:21:11 2011 +0200
@@ -283,6 +283,29 @@
 				imapc_list_simple_callback, ctx);
 }
 
+static void imapc_list_delete_unused_indexes(struct imapc_mailbox_list *list)
+{
+	struct mailbox_list *fs_list = imapc_list_get_fs(list);
+	struct mailbox_list_iterate_context *iter;
+	const struct mailbox_info *info;
+	const char *fs_name;
+
+	if (fs_list == NULL)
+		return;
+
+	iter = mailbox_list_iter_init(fs_list, "*",
+				      MAILBOX_LIST_ITER_NO_AUTO_BOXES |
+				      MAILBOX_LIST_ITER_RETURN_NO_FLAGS);
+	while ((info = mailbox_list_iter_next(iter)) != NULL) {
+		if (mailbox_tree_lookup(list->mailboxes, info->name) == NULL) {
+			fs_name = mailbox_list_get_storage_name(fs_list,
+								info->name);
+			(void)fs_list->v.delete_mailbox(fs_list, fs_name);
+		}
+	}
+	(void)mailbox_list_iter_deinit(&iter);
+}
+
 static int imapc_list_refresh(struct imapc_mailbox_list *list)
 {
 	struct imapc_command *cmd;
@@ -299,8 +322,10 @@
 	list->mailboxes = mailbox_tree_init(list->sep);
 
 	imapc_simple_run(&ctx);
-	if (ctx.ret == 0)
+	if (ctx.ret == 0) {
 		list->refreshed_mailboxes = TRUE;
+		imapc_list_delete_unused_indexes(list);
+	}
 	return ctx.ret;
 }
 


More information about the dovecot-cvs mailing list