Mercurial > dovecot > core-2.2
changeset 20079:4c000172dd34
fts-lucene: Cleanup - move code to a separate function
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Mon, 25 Apr 2016 20:13:54 +0300 |
parents | 776abe15fd59 |
children | e0a1dd0655fb |
files | src/plugins/fts-lucene/lucene-wrapper.cc |
diffstat | 1 files changed, 25 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/fts-lucene/lucene-wrapper.cc Mon Apr 25 16:58:30 2016 +0300 +++ b/src/plugins/fts-lucene/lucene-wrapper.cc Mon Apr 25 20:13:54 2016 +0300 @@ -819,6 +819,29 @@ } } +static void +rescan_clear_unseen_mailbox(struct rescan_context *rescan_ctx, + const char *vname, + const struct fts_index_header *hdr) +{ + struct mailbox *box; + struct mailbox_metadata metadata; + + box = mailbox_alloc(rescan_ctx->index->list, vname, + (enum mailbox_flags)0); + if (mailbox_open(box) == 0 && + mailbox_get_metadata(box, MAILBOX_METADATA_GUID, + &metadata) == 0 && + (rescan_ctx == NULL || + hash_table_lookup(rescan_ctx->seen_mailbox_guids, + metadata.guid) == NULL)) { + /* this mailbox had no records in lucene index. + make sure its last indexed uid is 0 */ + (void)fts_index_set_header(box, hdr); + } + mailbox_free(&box); +} + static void rescan_clear_unseen_mailboxes(struct lucene_index *index, struct rescan_context *rescan_ctx) { @@ -828,29 +851,14 @@ MAILBOX_LIST_ITER_RETURN_NO_FLAGS); struct mailbox_list_iterate_context *iter; const struct mailbox_info *info; - struct mailbox *box; - struct mailbox_metadata metadata; struct fts_index_header hdr; memset(&hdr, 0, sizeof(hdr)); hdr.settings_checksum = fts_lucene_settings_checksum(&index->set); iter = mailbox_list_iter_init(index->list, "*", iter_flags); - while ((info = mailbox_list_iter_next(iter)) != NULL) { - box = mailbox_alloc(index->list, info->vname, - (enum mailbox_flags)0); - if (mailbox_open(box) == 0 && - mailbox_get_metadata(box, MAILBOX_METADATA_GUID, - &metadata) == 0 && - (rescan_ctx == NULL || - hash_table_lookup(rescan_ctx->seen_mailbox_guids, - metadata.guid) == NULL)) { - /* this mailbox had no records in lucene index. - make sure its last indexed uid is 0 */ - (void)fts_index_set_header(box, &hdr); - } - mailbox_free(&box); - } + while ((info = mailbox_list_iter_next(iter)) != NULL) + rescan_clear_unseen_mailbox(rescan_ctx, info->vname, &hdr); (void)mailbox_list_iter_deinit(&iter); }