Mercurial > dovecot > core-2.2
changeset 21293:0b5ede227460
lib-index: Add mail_index_revert_changes()
This can be used to revert changes done in a transaction to the specified
existing mail.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Tue, 13 Dec 2016 18:31:41 +0200 |
parents | 25b0616d7f1c |
children | dfa20786a81d |
files | src/lib-index/mail-index-transaction-update.c src/lib-index/mail-index.h |
diffstat | 2 files changed, 21 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-index-transaction-update.c Wed Dec 14 10:23:17 2016 +0200 +++ b/src/lib-index/mail-index-transaction-update.c Tue Dec 13 18:31:41 2016 +0200 @@ -282,8 +282,8 @@ } static void -mail_index_expunge_last_append_ext(ARRAY_TYPE(seq_array_array) *ext_updates, - uint32_t seq) +mail_index_revert_ext(ARRAY_TYPE(seq_array_array) *ext_updates, + uint32_t seq) { ARRAY_TYPE(seq_array) *seqs; unsigned int idx; @@ -299,16 +299,14 @@ } static void -mail_index_expunge_last_append(struct mail_index_transaction *t, uint32_t seq) +mail_index_revert_changes_common(struct mail_index_transaction *t, uint32_t seq) { struct mail_index_transaction_keyword_update *kw_update; unsigned int i; - i_assert(seq == t->last_new_seq); - /* remove extension updates */ - mail_index_expunge_last_append_ext(&t->ext_rec_updates, seq); - mail_index_expunge_last_append_ext(&t->ext_rec_atomics, seq); + mail_index_revert_ext(&t->ext_rec_updates, seq); + mail_index_revert_ext(&t->ext_rec_atomics, seq); t->log_ext_updates = mail_index_transaction_has_ext_changes(t); /* remove keywords */ @@ -328,6 +326,20 @@ if (array_is_created(&t->modseq_updates) && mail_index_seq_array_lookup((void *)&t->modseq_updates, seq, &i)) array_delete(&t->modseq_updates, i, 1); +} + +void mail_index_revert_changes(struct mail_index_transaction *t, uint32_t seq) +{ + mail_index_revert_changes_common(t, seq); + mail_index_cancel_flag_updates(t, seq); +} + +static void +mail_index_expunge_last_append(struct mail_index_transaction *t, uint32_t seq) +{ + i_assert(seq == t->last_new_seq); + + mail_index_revert_changes_common(t, seq); /* and finally remove the append itself */ array_delete(&t->appends, seq - t->first_new_seq, 1);
--- a/src/lib-index/mail-index.h Wed Dec 14 10:23:17 2016 +0200 +++ b/src/lib-index/mail-index.h Tue Dec 13 18:31:41 2016 +0200 @@ -497,6 +497,8 @@ /* Like mail_index_expunge(), but also write message GUID to transaction log. */ void mail_index_expunge_guid(struct mail_index_transaction *t, uint32_t seq, const guid_128_t guid_128); +/* Revert all changes done in this transaction to the given existing mail. */ +void mail_index_revert_changes(struct mail_index_transaction *t, uint32_t seq); /* Update flags in index. */ void mail_index_update_flags(struct mail_index_transaction *t, uint32_t seq, enum modify_type modify_type,