Mercurial > dovecot > core-2.2
changeset 9725:1411f157ffdd HEAD
lib-index: Added mail_index_update_highest_modseq().
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 05 Aug 2009 20:01:34 -0400 |
parents | 773b91d3ed13 |
children | dd4c5e43c55a |
files | src/lib-index/mail-index-sync-update.c src/lib-index/mail-index-transaction-finish.c src/lib-index/mail-index-transaction-private.h src/lib-index/mail-index-transaction-update.c src/lib-index/mail-index.h src/lib-index/test-mail-index-transaction-finish.c |
diffstat | 6 files changed, 29 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-index-sync-update.c Wed Aug 05 20:01:02 2009 -0400 +++ b/src/lib-index/mail-index-sync-update.c Wed Aug 05 20:01:34 2009 -0400 @@ -325,14 +325,17 @@ end = CONST_PTR_OFFSET(u, size); for (; u < end; u++) { - if (!mail_index_lookup_seq(view, u->uid, &seq)) + if (u->uid == 0) + seq = 0; + else if (!mail_index_lookup_seq(view, u->uid, &seq)) continue; min_modseq = ((uint64_t)u->modseq_high32 >> 32) | u->modseq_low32; if (highest_modseq < min_modseq) highest_modseq = min_modseq; - if (mail_index_modseq_set(view, seq, min_modseq) < 0) { + if (seq != 0 && + mail_index_modseq_set(view, seq, min_modseq) < 0) { mail_index_sync_set_corrupted(ctx, "modseqs updated before they were enabled"); return -1;
--- a/src/lib-index/mail-index-transaction-finish.c Wed Aug 05 20:01:02 2009 -0400 +++ b/src/lib-index/mail-index-transaction-finish.c Wed Aug 05 20:01:34 2009 -0400 @@ -342,5 +342,9 @@ /* finally convert all sequences to UIDs before we write them, but after we've checked and removed conflicts */ mail_index_transaction_convert_to_uids(t); + + /* and kind of ugly way to update highest modseq */ + if (t->min_highest_modseq != 0) + mail_index_update_modseq(t, 0, t->min_highest_modseq); return 0; }
--- a/src/lib-index/mail-index-transaction-private.h Wed Aug 05 20:01:02 2009 -0400 +++ b/src/lib-index/mail-index-transaction-private.h Wed Aug 05 20:01:34 2009 -0400 @@ -68,6 +68,7 @@ struct mail_index_transaction_keyword_update); ARRAY_TYPE(seq_range) keyword_resets; + uint64_t min_highest_modseq; uint64_t max_modseq; ARRAY_TYPE(seq_range) *conflict_seqs;
--- a/src/lib-index/mail-index-transaction-update.c Wed Aug 05 20:01:02 2009 -0400 +++ b/src/lib-index/mail-index-transaction-update.c Wed Aug 05 20:01:34 2009 -0400 @@ -91,6 +91,7 @@ t->last_update_idx = 0; t->min_flagupdate_seq = 0; t->max_flagupdate_seq = 0; + t->min_highest_modseq = 0; memset(t->pre_hdr_mask, 0, sizeof(t->pre_hdr_mask)); memset(t->post_hdr_mask, 0, sizeof(t->post_hdr_mask)); @@ -114,7 +115,8 @@ array_is_created(&t->expunges) || array_is_created(&t->keyword_resets) || array_is_created(&t->keyword_updates) || - t->pre_hdr_changed || t->post_hdr_changed; + t->pre_hdr_changed || t->post_hdr_changed || + t->min_highest_modseq != 0; } void mail_index_update_day_headers(struct mail_index_transaction *t) @@ -268,6 +270,17 @@ u->uid = seq; u->modseq_low32 = min_modseq & 0xffffffff; u->modseq_high32 = min_modseq >> 32; + + t->log_updates = TRUE; +} + +void mail_index_update_highest_modseq(struct mail_index_transaction *t, + uint64_t min_modseq) +{ + if (t->min_highest_modseq < min_modseq) + t->min_highest_modseq = min_modseq; + + t->log_updates = TRUE; } static void
--- a/src/lib-index/mail-index.h Wed Aug 05 20:01:02 2009 -0400 +++ b/src/lib-index/mail-index.h Wed Aug 05 20:01:34 2009 -0400 @@ -426,6 +426,9 @@ /* Update message's modseq to be at least min_modseq. */ void mail_index_update_modseq(struct mail_index_transaction *t, uint32_t seq, uint64_t min_modseq); +/* Update highest modseq to be at least min_modseq. */ +void mail_index_update_highest_modseq(struct mail_index_transaction *t, + uint64_t min_modseq); /* Reset the index before committing this transaction. This is usually done only when UIDVALIDITY changes. */ void mail_index_reset(struct mail_index_transaction *t);
--- a/src/lib-index/test-mail-index-transaction-finish.c Wed Aug 05 20:01:02 2009 -0400 +++ b/src/lib-index/test-mail-index-transaction-finish.c Wed Aug 05 20:01:34 2009 -0400 @@ -27,6 +27,8 @@ void mail_index_transaction_sort_appends(struct mail_index_transaction *t ATTR_UNUSED) {} int mail_index_map(struct mail_index *index ATTR_UNUSED, enum mail_index_sync_handler_type type ATTR_UNUSED) { return 1; } +void mail_index_update_modseq(struct mail_index_transaction *t ATTR_UNUSED, uint32_t seq ATTR_UNUSED, + uint64_t min_modseq ATTR_UNUSED) {} const struct mail_index_record * mail_index_lookup(struct mail_index_view *view ATTR_UNUSED, uint32_t seq)