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;
/* 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;
}
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;
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));
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)
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
/* 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);
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)