Mercurial > dovecot > original-hg > dovecot-1.2
changeset 8510:ac872ae669ff HEAD
autocreate plugin: If mail_debug=yes, log the reason why mailbox creation fails.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 01 Dec 2008 00:04:27 +0200 |
parents | 2eede4287841 |
children | bd145a5c5482 |
files | src/plugins/autocreate/autocreate-plugin.c |
diffstat | 1 files changed, 24 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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_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 @@ 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);