dovecot-2.2: lib-storage: Added optional mailbox_list.init(), wh...

dovecot at dovecot.org dovecot at dovecot.org
Fri Oct 12 03:47:52 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/a44be96f55c1
changeset: 15209:a44be96f55c1
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Oct 12 03:47:41 2012 +0300
description:
lib-storage: Added optional mailbox_list.init(), which can check for failure.
"index" backend now gives a nice error message instead of crashing when
mailbox_list_index=no

diffstat:

 src/lib-storage/index/imapc/imapc-list.c          |   1 +
 src/lib-storage/index/shared/shared-list.c        |   1 +
 src/lib-storage/list/mailbox-list-fs.c            |   1 +
 src/lib-storage/list/mailbox-list-index-backend.c |  10 ++++++++++
 src/lib-storage/list/mailbox-list-maildir.c       |   2 ++
 src/lib-storage/list/mailbox-list-none.c          |   1 +
 src/lib-storage/mailbox-list-private.h            |   1 +
 src/lib-storage/mailbox-list.c                    |   7 +++++++
 8 files changed, 24 insertions(+), 0 deletions(-)

diffs (118 lines):

diff -r 269104a0821b -r a44be96f55c1 src/lib-storage/index/imapc/imapc-list.c
--- a/src/lib-storage/index/imapc/imapc-list.c	Fri Oct 12 03:17:56 2012 +0300
+++ b/src/lib-storage/index/imapc/imapc-list.c	Fri Oct 12 03:47:41 2012 +0300
@@ -664,6 +664,7 @@
 
 	{
 		imapc_list_alloc,
+		NULL,
 		imapc_list_deinit,
 		NULL,
 		imapc_list_get_hierarchy_sep,
diff -r 269104a0821b -r a44be96f55c1 src/lib-storage/index/shared/shared-list.c
--- a/src/lib-storage/index/shared/shared-list.c	Fri Oct 12 03:17:56 2012 +0300
+++ b/src/lib-storage/index/shared/shared-list.c	Fri Oct 12 03:47:41 2012 +0300
@@ -281,6 +281,7 @@
 
 	{
 		shared_list_alloc,
+		NULL,
 		shared_list_deinit,
 		shared_get_storage,
 		shared_list_get_hierarchy_sep,
diff -r 269104a0821b -r a44be96f55c1 src/lib-storage/list/mailbox-list-fs.c
--- a/src/lib-storage/list/mailbox-list-fs.c	Fri Oct 12 03:17:56 2012 +0300
+++ b/src/lib-storage/list/mailbox-list-fs.c	Fri Oct 12 03:47:41 2012 +0300
@@ -481,6 +481,7 @@
 
 	{
 		fs_list_alloc,
+		NULL,
 		fs_list_deinit,
 		NULL,
 		fs_list_get_hierarchy_sep,
diff -r 269104a0821b -r a44be96f55c1 src/lib-storage/list/mailbox-list-index-backend.c
--- a/src/lib-storage/list/mailbox-list-index-backend.c	Fri Oct 12 03:17:56 2012 +0300
+++ b/src/lib-storage/list/mailbox-list-index-backend.c	Fri Oct 12 03:47:41 2012 +0300
@@ -34,6 +34,15 @@
 	return &list->list;
 }
 
+static int index_list_init(struct mailbox_list *_list, const char **error_r)
+{
+	if (!_list->mail_set->mailbox_list_index) {
+		*error_r = "LAYOUT=index requires mailbox_list_index=yes";
+		return -1;
+	}
+	return 0;
+}
+
 static void index_list_deinit(struct mailbox_list *_list)
 {
 	struct index_mailbox_list *list = (struct index_mailbox_list *)_list;
@@ -555,6 +564,7 @@
 
 	{
 		index_list_alloc,
+		index_list_init,
 		index_list_deinit,
 		NULL,
 		index_list_get_hierarchy_sep,
diff -r 269104a0821b -r a44be96f55c1 src/lib-storage/list/mailbox-list-maildir.c
--- a/src/lib-storage/list/mailbox-list-maildir.c	Fri Oct 12 03:17:56 2012 +0300
+++ b/src/lib-storage/list/mailbox-list-maildir.c	Fri Oct 12 03:47:41 2012 +0300
@@ -476,6 +476,7 @@
 
 	{
 		maildir_list_alloc,
+		NULL,
 		maildir_list_deinit,
 		NULL,
 		maildir_list_get_hierarchy_sep,
@@ -508,6 +509,7 @@
 
 	{
 		imapdir_list_alloc,
+		NULL,
 		maildir_list_deinit,
 		NULL,
 		maildir_list_get_hierarchy_sep,
diff -r 269104a0821b -r a44be96f55c1 src/lib-storage/list/mailbox-list-none.c
--- a/src/lib-storage/list/mailbox-list-none.c	Fri Oct 12 03:17:56 2012 +0300
+++ b/src/lib-storage/list/mailbox-list-none.c	Fri Oct 12 03:47:41 2012 +0300
@@ -158,6 +158,7 @@
 
 	{
 		none_list_alloc,
+		NULL,
 		none_list_deinit,
 		NULL,
 		none_list_get_hierarchy_sep,
diff -r 269104a0821b -r a44be96f55c1 src/lib-storage/mailbox-list-private.h
--- a/src/lib-storage/mailbox-list-private.h	Fri Oct 12 03:17:56 2012 +0300
+++ b/src/lib-storage/mailbox-list-private.h	Fri Oct 12 03:47:41 2012 +0300
@@ -27,6 +27,7 @@
 
 struct mailbox_list_vfuncs {
 	struct mailbox_list *(*alloc)(void);
+	int (*init)(struct mailbox_list *list, const char **error_r);
 	void (*deinit)(struct mailbox_list *list);
 
 	int (*get_storage)(struct mailbox_list **list, const char *vname,
diff -r 269104a0821b -r a44be96f55c1 src/lib-storage/mailbox-list.c
--- a/src/lib-storage/mailbox-list.c	Fri Oct 12 03:17:56 2012 +0300
+++ b/src/lib-storage/mailbox-list.c	Fri Oct 12 03:47:41 2012 +0300
@@ -179,6 +179,13 @@
 	}
 	list->set.utf8 = set->utf8;
 
+	if (list->v.init != NULL) {
+		if (list->v.init(list, error_r) < 0) {
+			list->v.deinit(list);
+			return -1;
+		}
+	}
+
 	if (ns->mail_set->mail_debug) {
 		i_debug("%s: root=%s, index=%s, indexpvt=%s, control=%s, inbox=%s, alt=%s",
 			list->name,


More information about the dovecot-cvs mailing list