changeset 21236:dff211013d38

mail-crypt: Commit transaction before lookup in test Key cannot be found if it's not committed before.
author Aki Tuomi <aki.tuomi@dovecot.fi>
date Mon, 28 Nov 2016 12:16:26 +0200
parents e5e29b17b8a2
children a0be55f275c5
files src/plugins/mail-crypt/test-mail-key.c
diffstat 1 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/mail-crypt/test-mail-key.c	Fri Nov 25 01:45:29 2016 +0200
+++ b/src/plugins/mail-crypt/test-mail-key.c	Mon Nov 28 12:16:26 2016 +0200
@@ -119,13 +119,12 @@
 	attr_value.value = value;
 
 	if ((ret = mailbox_attribute_set(t, attr_type,
-					 attr_name, &attr_value)) <= 0) {
-		if (ret < 0) {
-			*error_r = t_strdup_printf("mailbox_attribute_set(%s, %s) failed: %s",
-						   mailbox_get_vname(mailbox_transaction_get_mailbox(t)),
-						   attr_name,
-						   mailbox_get_last_error(mailbox_transaction_get_mailbox(t), NULL));
-		}
+					 attr_name, &attr_value)) < 0) {
+		*error_r = t_strdup_printf("mailbox_attribute_set(%s, %s) failed: %s",
+					   mailbox_get_vname(mailbox_transaction_get_mailbox(t)),
+					   attr_name,
+					   mailbox_get_last_error(mailbox_transaction_get_mailbox(t), NULL));
+
 	}
 
 	return ret;
@@ -413,6 +412,10 @@
 	test_mail_attribute_set(t, FALSE, FALSE, mcp_old_box_key_id,
 				mcp_old_box_key, &error);
 
+	(void)mailbox_transaction_commit(&t);
+
+	t = mailbox_transaction_begin(box, 0);
+
 	error = NULL;
 
 	/* try to load old key */