[dovecot-cvs] dovecot/src/imap cmd-append.c,1.88,1.89

tss at dovecot.org tss at dovecot.org
Thu Feb 15 11:38:50 UTC 2007


Update of /var/lib/cvs/dovecot/src/imap
In directory talvi:/tmp/cvs-serv20362

Modified Files:
	cmd-append.c 
Log Message:
If we've a mailbox selected and we're appending to another mailbox, we got
extra FLAGS/PERMANENTFLAGS change notifications.



Index: cmd-append.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/imap/cmd-append.c,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -d -r1.88 -r1.89
--- cmd-append.c	6 Feb 2007 12:56:13 -0000	1.88
+++ cmd-append.c	15 Feb 2007 11:38:48 -0000	1.89
@@ -24,6 +24,7 @@
 
 	struct imap_parser *save_parser;
 	struct mail_save_context *save_ctx;
+	struct mailbox_keywords old_keywords;
 
 	unsigned int message_input:1;
 };
@@ -122,8 +123,12 @@
 		mailbox_save_cancel(&ctx->save_ctx);
 	if (ctx->t != NULL)
 		mailbox_transaction_rollback(&ctx->t);
-	if (ctx->box != ctx->cmd->client->mailbox && ctx->box != NULL)
+	if (ctx->box != ctx->cmd->client->mailbox && ctx->box != NULL) {
 		mailbox_close(&ctx->box);
+
+		pool_unref(ctx->client->keywords.pool);
+		ctx->client->keywords = ctx->old_keywords;
+	}
 }
 
 static bool cmd_append_continue_cancel(struct client_command_context *cmd)
@@ -398,11 +403,34 @@
 	return box;
 }
 
+static int get_keywords(struct cmd_append_context *ctx)
+{
+	struct client *client = ctx->client;
+	struct mailbox_status status;
+
+	/* we'll need to get the current keywords so that
+	   client_parse_mail_flags()'s keyword verification works.
+	   however if we're not appending to selected mailbox, we'll
+	   need to restore the keywords list. */
+	if (mailbox_get_status(ctx->box, STATUS_KEYWORDS,
+			       &status) < 0)
+		return -1;
+
+	if (ctx->box != client->mailbox) {
+		ctx->old_keywords = client->keywords;
+
+		memset(&client->keywords, 0, sizeof(client->keywords));
+		client->keywords.pool =
+			pool_alloconly_create("append keywords pool", 128);
+	}
+	client_save_keywords(&client->keywords, status.keywords);
+	return 0;
+}
+
 bool cmd_append(struct client_command_context *cmd)
 {
 	struct client *client = cmd->client;
         struct cmd_append_context *ctx;
-	struct mailbox_status status;
 	const char *mailbox;
 
 	/* <mailbox> */
@@ -419,17 +447,13 @@
 	if (ctx->box != NULL) {
 		ctx->storage = mailbox_get_storage(ctx->box);
 
-		if (mailbox_get_status(ctx->box, STATUS_KEYWORDS,
-				       &status) < 0) {
+		if (get_keywords(ctx) < 0) {
 			client_send_storage_error(cmd, ctx->storage);
 			mailbox_close(&ctx->box);
 		} else {
-			client_save_keywords(&client->keywords,
-					     status.keywords);
+			ctx->t = mailbox_transaction_begin(ctx->box,
+					MAILBOX_TRANSACTION_FLAG_EXTERNAL);
 		}
-		ctx->t = ctx->box == NULL ? NULL :
-			mailbox_transaction_begin(ctx->box,
-				MAILBOX_TRANSACTION_FLAG_EXTERNAL);
 	}
 
 	io_remove(&client->io);



More information about the dovecot-cvs mailing list