[dovecot-cvs] dovecot/src/imap cmd-append.c,1.80.2.2,1.80.2.3

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


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

Modified Files:
      Tag: branch_1_0
	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.80.2.2
retrieving revision 1.80.2.3
diff -u -d -r1.80.2.2 -r1.80.2.3
--- cmd-append.c	6 Feb 2007 12:54:57 -0000	1.80.2.2
+++ cmd-append.c	15 Feb 2007 11:38:45 -0000	1.80.2.3
@@ -24,6 +24,7 @@
 
 	struct imap_parser *save_parser;
 	struct mail_save_context *save_ctx;
+        struct mailbox_keywords old_keywords;
 };
 
 static void cmd_append_finish(struct cmd_append_context *ctx);
@@ -126,9 +127,13 @@
 	if (ctx->t != NULL)
 		mailbox_transaction_rollback(&ctx->t);
 
-	if (ctx->box != ctx->cmd->client->mailbox && ctx->box != NULL)
+	if (ctx->box != ctx->client->mailbox && ctx->box != NULL) {
 		mailbox_close(&ctx->box);
 
+		pool_unref(ctx->client->keywords.pool);
+		ctx->client->keywords = ctx->old_keywords;
+	}
+
 	ctx->client->bad_counter = 0;
 	o_stream_set_flush_callback(ctx->client->output,
 				    _client_output, ctx->client);
@@ -391,11 +396,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> */
@@ -409,17 +437,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