From 29337701451b9c9f9dd26b2aec23a31ab5203822 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 16 Mar 2011 17:42:42 +0200 Subject: [PATCH] lib-storage: Added min_first_recent_uid to struct mailbox_update. Implemented for dbox. Maildir/mbox needs some more code to make this work correctly. --- src/lib-storage/index/dbox-multi/mdbox-storage.c | 10 ++++++++++ src/lib-storage/index/dbox-single/sdbox-storage.c | 8 ++++++++ src/lib-storage/index/index-storage.c | 8 ++++++++ src/lib-storage/mail-storage.h | 1 + 4 files changed, 27 insertions(+) diff --git a/src/lib-storage/index/dbox-multi/mdbox-storage.c b/src/lib-storage/index/dbox-multi/mdbox-storage.c index 071dae02af..60ceef259f 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-storage.c +++ b/src/lib-storage/index/dbox-multi/mdbox-storage.c @@ -225,6 +225,16 @@ static int mdbox_write_index_header(struct mailbox *box, offsetof(struct mail_index_header, next_uid), &uid_next, sizeof(uid_next), TRUE); } + if (update->min_first_recent_uid != 0 && + hdr->first_recent_uid < update->min_first_recent_uid) { + uint32_t first_recent_uid = update->min_first_recent_uid; + + i_assert(update->min_next_uid == 0 || + first_recent_uid < update->min_next_uid); + mail_index_update_header(trans, + offsetof(struct mail_index_header, first_recent_uid), + &first_recent_uid, sizeof(first_recent_uid), FALSE); + } if (update != NULL && update->min_highest_modseq != 0 && mail_index_modseq_get_highest(box->view) < update->min_highest_modseq) { diff --git a/src/lib-storage/index/dbox-single/sdbox-storage.c b/src/lib-storage/index/dbox-single/sdbox-storage.c index 16806e1b09..a4c035b198 100644 --- a/src/lib-storage/index/dbox-single/sdbox-storage.c +++ b/src/lib-storage/index/dbox-single/sdbox-storage.c @@ -159,6 +159,14 @@ static int sdbox_mailbox_create_indexes(struct mailbox *box, offsetof(struct mail_index_header, next_uid), &uid_next, sizeof(uid_next), TRUE); } + if (update->min_first_recent_uid != 0 && + hdr->first_recent_uid < update->min_first_recent_uid) { + uint32_t first_recent_uid = update->min_first_recent_uid; + + mail_index_update_header(trans, + offsetof(struct mail_index_header, first_recent_uid), + &first_recent_uid, sizeof(first_recent_uid), FALSE); + } if (update != NULL && update->min_highest_modseq != 0 && mail_index_modseq_get_highest(box->view) < update->min_highest_modseq) { diff --git a/src/lib-storage/index/index-storage.c b/src/lib-storage/index/index-storage.c index 48547a3ee0..70a144f510 100644 --- a/src/lib-storage/index/index-storage.c +++ b/src/lib-storage/index/index-storage.c @@ -389,6 +389,14 @@ int index_storage_mailbox_update(struct mailbox *box, offsetof(struct mail_index_header, next_uid), &next_uid, sizeof(next_uid), FALSE); } + if (update->min_first_recent_uid != 0 && + hdr->first_recent_uid < update->min_first_recent_uid) { + uint32_t first_recent_uid = update->min_first_recent_uid; + + mail_index_update_header(trans, + offsetof(struct mail_index_header, first_recent_uid), + &first_recent_uid, sizeof(first_recent_uid), FALSE); + } if (update->min_highest_modseq != 0 && mail_index_modseq_get_highest(view) < update->min_highest_modseq) { mail_index_modseq_enable(box->index); diff --git a/src/lib-storage/mail-storage.h b/src/lib-storage/mail-storage.h index b98dd921f7..40412d7e57 100644 --- a/src/lib-storage/mail-storage.h +++ b/src/lib-storage/mail-storage.h @@ -203,6 +203,7 @@ struct mailbox_update { uint8_t mailbox_guid[MAIL_GUID_128_SIZE]; uint32_t uid_validity; uint32_t min_next_uid; + uint32_t min_first_recent_uid; uint64_t min_highest_modseq; /* Add these fields to be temporarily cached, if they aren't already. */ const char *const *cache_fields; -- 2.47.3