dovecot-1.0: If we can't open/create the wanted mailbox, log an ...

dovecot at dovecot.org dovecot at dovecot.org
Mon Dec 3 18:53:08 EET 2007


details:   http://hg.dovecot.org/dovecot-1.0/rev/d0581c8dccfa
changeset: 5481:d0581c8dccfa
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Dec 03 18:53:05 2007 +0200
description:
If we can't open/create the wanted mailbox, log an error.

diffstat:

1 file changed, 11 insertions(+), 9 deletions(-)
src/deliver/deliver.c |   20 +++++++++++---------

diffs (48 lines):

diff -r d8c37fc98a07 -r d0581c8dccfa src/deliver/deliver.c
--- a/src/deliver/deliver.c	Mon Dec 03 11:45:20 2007 +0200
+++ b/src/deliver/deliver.c	Mon Dec 03 18:53:05 2007 +0200
@@ -122,15 +122,24 @@ int deliver_save(struct mail_storage *st
 	struct mailbox *box;
 	struct mailbox_transaction_context *t;
 	struct mail_keywords *kw;
-	const char *msgid, *mailbox_name;
+	const char *msgid, *mailbox_name, *error;
+	bool syntax, temp;
 	int ret = 0;
 
 	if (strcmp(mailbox, default_mailbox_name) == 0)
 		tried_default_save = TRUE;
 
+	msgid = mail_get_first_header(mail, "Message-ID");
+	msgid = msgid == NULL ? "" : str_sanitize(msgid, 80);
+	mailbox_name = str_sanitize(mailbox, 80);
+
 	box = mailbox_open_or_create_synced(storage, mailbox);
-	if (box == NULL)
+	if (box == NULL) {
+		error = mail_storage_get_last_error(storage, &syntax, &temp);
+		i_info("msgid=%s: Couldn't open mailbox %s: %s",
+		       msgid, mailbox_name, error);
 		return -1;
+	}
 
 	t = mailbox_transaction_begin(box, MAILBOX_TRANSACTION_FLAG_EXTERNAL);
 
@@ -145,17 +154,10 @@ int deliver_save(struct mail_storage *st
 	else
 		ret = mailbox_transaction_commit(&t, 0);
 
-	msgid = mail_get_first_header(mail, "Message-ID");
-	msgid = msgid == NULL ? "" : str_sanitize(msgid, 80);
-	mailbox_name = str_sanitize(mailbox_get_name(box), 80);
-
 	if (ret == 0) {
 		saved_mail = TRUE;
 		i_info("msgid=%s: saved mail to %s", msgid, mailbox_name);
 	} else {
-		const char *error;
-		bool syntax, temp;
-
 		error = ret == -2 ? "BUG: Input mail got lost unexpectedly" :
 			mail_storage_get_last_error(storage, &syntax, &temp);
 		i_info("msgid=%s: save failed to %s: %s",


More information about the dovecot-cvs mailing list