dovecot-1.2: autocreate plugin: If mail_debug=yes, log the reaso...

dovecot at dovecot.org dovecot at dovecot.org
Mon Dec 1 00:04:31 EET 2008


details:   http://hg.dovecot.org/dovecot-1.2/rev/ac872ae669ff
changeset: 8510:ac872ae669ff
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Dec 01 00:04:27 2008 +0200
description:
autocreate plugin: If mail_debug=yes, log the reason why mailbox creation fails.

diffstat:

1 file changed, 24 insertions(+), 6 deletions(-)
src/plugins/autocreate/autocreate-plugin.c |   30 ++++++++++++++++++++++------

diffs (49 lines):

diff -r 2eede4287841 -r ac872ae669ff src/plugins/autocreate/autocreate-plugin.c
--- a/src/plugins/autocreate/autocreate-plugin.c	Sun Nov 30 16:29:17 2008 +0200
+++ b/src/plugins/autocreate/autocreate-plugin.c	Mon Dec 01 00:04:27 2008 +0200
@@ -12,9 +12,31 @@ static void (*autocreate_next_hook_mail_
 static void (*autocreate_next_hook_mail_namespaces_created)
 	(struct mail_namespace *ns);
 
+static void
+autocreate_mailbox(struct mail_namespace *namespaces, const char *name)
+{
+	struct mail_namespace *ns;
+	const char *str;
+	enum mail_error error;
+
+	ns = mail_namespace_find(namespaces, &name);
+	if (ns == NULL) {
+		if (getenv("DEBUG") != NULL)
+			i_info("autocreate: No namespace found for %s", name);
+		return;
+	}
+
+	if (mail_storage_mailbox_create(ns->storage, name, FALSE) < 0) {
+		str = mail_storage_get_last_error(ns->storage, &error);
+		if (error != MAIL_ERROR_EXISTS && getenv("DEBUG") != NULL) {
+			i_info("autocreate: Failed to create mailbox %s: %s",
+			       name, str);
+		}
+	}
+}
+
 static void autocreate_mailboxes(struct mail_namespace *namespaces)
 {
-	struct mail_namespace *ns;
 	char env_name[20];
 	const char *name;
 	unsigned int i;
@@ -22,11 +44,7 @@ static void autocreate_mailboxes(struct 
 	i = 1;
 	name = getenv("AUTOCREATE");
 	while (name != NULL) {
-		ns = mail_namespace_find(namespaces, &name);
-		if (ns != NULL) {
-			(void)mail_storage_mailbox_create(ns->storage,
-							  name, FALSE);
-		}
+		autocreate_mailbox(namespaces, name);
 
 		i_snprintf(env_name, sizeof(env_name), "AUTOCREATE%d", ++i);
 		name = getenv(env_name);


More information about the dovecot-cvs mailing list