mail-index-sync-update.c revision d9e49848cb4a08f140892d76c2b54afabb9e675a
02c335c23bf5fa225a467c19f2c063fb0dc7b8c3Timo Sirainen/* Copyright (C) 2004 Timo Sirainen */
3008b30900f4de3e76f1a6d289444eb694f3d17cTimo Sirainenmail_index_header_update_counts(struct mail_index_header *hdr,
3008b30900f4de3e76f1a6d289444eb694f3d17cTimo Sirainen if (((old_flags ^ new_flags) & MAIL_RECENT) != 0) {
3008b30900f4de3e76f1a6d289444eb694f3d17cTimo Sirainen /* different recent-flag */
8aa049fd90cd03a66ec43018554bf3ba06815a10Timo Sirainen hdr->first_recent_uid_lowwater = hdr->next_uid;
3008b30900f4de3e76f1a6d289444eb694f3d17cTimo Sirainen if (((old_flags ^ new_flags) & MAIL_SEEN) != 0) {
3008b30900f4de3e76f1a6d289444eb694f3d17cTimo Sirainen /* different seen-flag */
3008b30900f4de3e76f1a6d289444eb694f3d17cTimo Sirainen else if (++hdr->seen_messages_count == hdr->messages_count)
3008b30900f4de3e76f1a6d289444eb694f3d17cTimo Sirainen hdr->first_unseen_uid_lowwater = hdr->next_uid;
3008b30900f4de3e76f1a6d289444eb694f3d17cTimo Sirainen if (((old_flags ^ new_flags) & MAIL_DELETED) != 0) {
477082109e06b912d868a2c05674f44cb880875bTimo Sirainen /* different deleted-flag */
3008b30900f4de3e76f1a6d289444eb694f3d17cTimo Sirainen hdr->first_deleted_uid_lowwater = hdr->next_uid;
3008b30900f4de3e76f1a6d289444eb694f3d17cTimo Sirainenmail_index_header_update_lowwaters(struct mail_index_header *hdr,
3008b30900f4de3e76f1a6d289444eb694f3d17cTimo Sirainenstatic int sync_expunge(const struct mail_transaction_expunge *e, void *context)
3008b30900f4de3e76f1a6d289444eb694f3d17cTimo Sirainen struct mail_index_header *hdr = &map->hdr_copy;
3008b30900f4de3e76f1a6d289444eb694f3d17cTimo Sirainen ret = mail_index_lookup_uid_range(view, e->uid1, e->uid2, &seq1, &seq2);
3008b30900f4de3e76f1a6d289444eb694f3d17cTimo Sirainen mail_index_header_update_counts(hdr, rec->flags, 0);
9346506a9f4dd9a6285fe8595588e73161849235Timo Sirainen /* @UNSAFE */
9346506a9f4dd9a6285fe8595588e73161849235Timo Sirainen memmove(MAIL_INDEX_MAP_IDX(map, seq1-1), MAIL_INDEX_MAP_IDX(map, seq2),
9346506a9f4dd9a6285fe8595588e73161849235Timo Sirainen (map->records_count - seq2) * map->hdr->record_size);
3008b30900f4de3e76f1a6d289444eb694f3d17cTimo Sirainen buffer_set_used_size(map->buffer, map->records_count *
3008b30900f4de3e76f1a6d289444eb694f3d17cTimo Sirainen map->records = buffer_get_modifyable_data(map->buffer, NULL);
3008b30900f4de3e76f1a6d289444eb694f3d17cTimo Sirainenstatic int sync_append(const struct mail_transaction_append_header *hdr,
3008b30900f4de3e76f1a6d289444eb694f3d17cTimo Sirainen const struct mail_index_record *rec, void *context)
3008b30900f4de3e76f1a6d289444eb694f3d17cTimo Sirainen i_assert(hdr->record_size <= map->hdr->record_size);
3008b30900f4de3e76f1a6d289444eb694f3d17cTimo Sirainen mail_transaction_log_view_set_corrupted(view->log_view,
4209bd278ff41fe352e8b993d849a061152829c8Timo Sirainen "Append with UID %u, but next_uid = %u",
4209bd278ff41fe352e8b993d849a061152829c8Timo Sirainen i_assert(map->records_count * map->hdr->record_size ==
4209bd278ff41fe352e8b993d849a061152829c8Timo Sirainen dest = buffer_append_space_unsafe(map->buffer,
4209bd278ff41fe352e8b993d849a061152829c8Timo Sirainen map->records = buffer_get_modifyable_data(map->buffer, NULL);
4209bd278ff41fe352e8b993d849a061152829c8Timo Sirainen i_assert((map->records_count+1) * map->hdr->record_size <=
4209bd278ff41fe352e8b993d849a061152829c8Timo Sirainen dest = MAIL_INDEX_MAP_IDX(map, map->records_count);
3008b30900f4de3e76f1a6d289444eb694f3d17cTimo Sirainen mail_index_header_update_counts(&map->hdr_copy, 0, rec->flags);
3008b30900f4de3e76f1a6d289444eb694f3d17cTimo Sirainen mail_index_header_update_lowwaters(&map->hdr_copy, rec);
3008b30900f4de3e76f1a6d289444eb694f3d17cTimo Sirainenstatic int sync_flag_update(const struct mail_transaction_flag_update *u,
if (seq1 == 0)
for (i = 0; i < INDEX_KEYWORDS_BYTE_COUNT; i++) {
if (u->add_keywords[i] != 0 ||
u->remove_keywords[i] != 0)
if (update_keywords) {
for (i = 0; i < INDEX_KEYWORDS_BYTE_COUNT; i++) {
void *context)
uint32_t i;
void *context)
int ret;
if (seq != 0) {
u->cache_offset;
void *context)
void *data;
const struct mail_transaction_extra_rec_update *u,
void *context)
int ret;
if (seq != 0) {
unsigned int count)
const int max_days =
int i, days;
const void *data;
first_append_uid = 0;
if (had_dirty)
if (first_append_uid == 0)
view) < 0) {
if (ret < 0) {
if (first_append_uid != 0)
had_dirty) {
return ret;