Mercurial > dovecot > core-2.2
changeset 12792:2762bb5a7481
lib-index: If keyword is added and remove within transaction, don't write a broken keyword update.
This could have caused "No UID ranges (type=0x400)" errors.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 25 Feb 2011 10:55:34 +0200 |
parents | 2480413a80fb |
children | 067f038ded8b |
files | src/lib-index/mail-index-transaction-export.c |
diffstat | 1 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-index-transaction-export.c Tue Feb 22 15:44:42 2011 +0200 +++ b/src/lib-index/mail-index-transaction-export.c Fri Feb 25 10:55:34 2011 +0200 @@ -285,10 +285,12 @@ static void log_append_keyword_update(struct mail_index_export_context *ctx, buffer_t *tmp_buf, enum modify_type modify_type, - const char *keyword, const buffer_t *buffer) + const char *keyword, const buffer_t *uid_buffer) { struct mail_transaction_keyword_update kt_hdr; + i_assert(uid_buffer->used > 0); + memset(&kt_hdr, 0, sizeof(kt_hdr)); kt_hdr.modify_type = modify_type; kt_hdr.name_size = strlen(keyword); @@ -298,7 +300,7 @@ buffer_append(tmp_buf, keyword, kt_hdr.name_size); if ((tmp_buf->used % 4) != 0) buffer_append_zero(tmp_buf, 4 - (tmp_buf->used % 4)); - buffer_append(tmp_buf, buffer->data, buffer->used); + buffer_append(tmp_buf, uid_buffer->data, uid_buffer->used); log_append_buffer(ctx, tmp_buf, MAIL_TRANSACTION_KEYWORD_UPDATE); } @@ -320,13 +322,15 @@ i_assert(count <= keywords_count); for (i = 0; i < count; i++) { - if (array_is_created(&updates[i].add_seq)) { + if (array_is_created(&updates[i].add_seq) && + array_count(&updates[i].add_seq) > 0) { change_mask |= MAIL_INDEX_SYNC_TYPE_KEYWORD_ADD; log_append_keyword_update(ctx, tmp_buf, MODIFY_ADD, keywords[i], updates[i].add_seq.arr.buffer); } - if (array_is_created(&updates[i].remove_seq)) { + if (array_is_created(&updates[i].remove_seq) && + array_count(&updates[i].remove_seq) > 0) { change_mask |= MAIL_INDEX_SYNC_TYPE_KEYWORD_REMOVE; log_append_keyword_update(ctx, tmp_buf, MODIFY_REMOVE, keywords[i],