]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Added mail_index_update_highest_modseq().
authorTimo Sirainen <tss@iki.fi>
Thu, 6 Aug 2009 00:01:34 +0000 (20:01 -0400)
committerTimo Sirainen <tss@iki.fi>
Thu, 6 Aug 2009 00:01:34 +0000 (20:01 -0400)
--HG--
branch : HEAD

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

index f60cb43d8119a88e0902fa57415edfd70be24489..370ff99f393ea6d9070930ff1bff565e66729111 100644 (file)
@@ -325,14 +325,17 @@ sync_modseq_update(struct mail_index_sync_map_ctx *ctx,
 
        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;
index 6a2e53438f8ee4aa39cf569f721737e4659d7c72..bd570fb72aea4196b9008dfa8373b0ec13a90f9c 100644 (file)
@@ -342,5 +342,9 @@ int mail_index_transaction_finish(struct mail_index_transaction *t)
        /* 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;
 }
index 19d4e51e2f6e5a48a3280372efd463b4a0be5625..a0cd0af78a1167b5005350367282487f832cae7e 100644 (file)
@@ -68,6 +68,7 @@ struct mail_index_transaction {
                     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;
 
index 490055c1a2acc3e3f34c2f73a555638dff0b0da7..9c7076fa60baf3ddfafa084e2e1508e57a8230ea 100644 (file)
@@ -91,6 +91,7 @@ void mail_index_transaction_reset_v(struct mail_index_transaction *t)
        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 @@ void mail_index_transaction_set_log_updates(struct mail_index_transaction *t)
                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 @@ void mail_index_update_modseq(struct mail_index_transaction *t, uint32_t seq,
        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
index 65ae7a0830d34d4670938566853903b991d873c2..8bbfe8bf39bb14020d0b9f117e52303e31dd6008 100644 (file)
@@ -426,6 +426,9 @@ void mail_index_update_flags_range(struct mail_index_transaction *t,
 /* 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);
index ddd18e5749e3fd8fcd00c4b9070d8f9bb515f33e..491da830c5a876add3a720b375435f0ecb82ee09 100644 (file)
@@ -27,6 +27,8 @@ bool mail_index_cancel_keyword_updates(struct mail_index_transaction *t ATTR_UNU
 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)