dovecot-2.2: imap: If GETMETADATA fails for some mailbox, don't ...

dovecot at dovecot.org dovecot at dovecot.org
Fri Jan 30 10:30:51 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/6e3b90370ad4
changeset: 18209:6e3b90370ad4
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Jan 30 12:29:25 2015 +0200
description:
imap: If GETMETADATA fails for some mailbox, don't send the error message mixed in the METADATA reply line.

diffstat:

 src/imap/cmd-getmetadata.c |  20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diffs (59 lines):

diff -r 2ef1371e0b77 -r 6e3b90370ad4 src/imap/cmd-getmetadata.c
--- a/src/imap/cmd-getmetadata.c	Fri Jan 30 12:19:58 2015 +0200
+++ b/src/imap/cmd-getmetadata.c	Fri Jan 30 12:29:25 2015 +0200
@@ -27,6 +27,8 @@
 	struct imap_metadata_iter *iter;
 	string_t *iter_entry_prefix;
 
+	string_t *delayed_errors;
+
 	unsigned int entry_idx;
 	bool first_entry_sent;
 	bool failed;
@@ -158,8 +160,10 @@
 		error_string = imap_metadata_transaction_get_last_error(
 			ctx->trans, &error);
 		if (error != MAIL_ERROR_NOTFOUND && error != MAIL_ERROR_PERM) {
-			client_send_line(client, t_strconcat("* NO ", error_string, NULL));
+			str_printfa(ctx->delayed_errors, "* NO %s\r\n",
+				    error_string);
 			ctx->failed = TRUE;
+			return;
 		}
 	}
 
@@ -265,9 +269,9 @@
 				/* iteration finished, get to the next entry */
 				if (imap_metadata_iter_deinit(&ctx->iter) < 0) {
 					enum mail_error error;
-					client_send_line(client, t_strconcat("* NO ",
-						imap_metadata_transaction_get_last_error(ctx->trans, &error),
-						NULL));
+
+					str_printfa(ctx->delayed_errors, "* NO %s\r\n",
+						imap_metadata_transaction_get_last_error(ctx->trans, &error));
 					ctx->failed = TRUE;
 				}
 				return -1;
@@ -364,6 +368,13 @@
 	if (ctx->first_entry_sent)
 		o_stream_nsend_str(cmd->client->output, ")\r\n");
 
+	if (str_len(ctx->delayed_errors) > 0) {
+		o_stream_nsend(cmd->client->output,
+			       str_data(ctx->delayed_errors),
+			       str_len(ctx->delayed_errors));
+		str_truncate(ctx->delayed_errors, 0);
+	}
+
 	cmd_getmetadata_iter_deinit(ctx);
 	if (ctx->list_iter != NULL)
 		return cmd_getmetadata_mailbox_iter_next(ctx);
@@ -469,6 +480,7 @@
 	ctx->cmd = cmd;
 	ctx->maxsize = (uint32_t)-1;
 	ctx->cmd->context = ctx;
+	ctx->delayed_errors = str_new(cmd->pool, 128);
 
 	if (imap_arg_get_list(&args[0], &options)) {
 		if (!cmd_getmetadata_parse_options(ctx, options))


More information about the dovecot-cvs mailing list