Mercurial > dovecot > core-2.2
changeset 16553:be970e7928eb
mdbox: Resize mdbox index header if necessary also when rebuilding indexes.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 25 Jun 2013 15:48:24 +0300 |
parents | 8cf482b749e2 |
children | d6b18c237be5 |
files | src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c |
diffstat | 1 files changed, 14 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Tue Jun 25 15:47:48 2013 +0300 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Tue Jun 25 15:48:24 2013 +0300 @@ -479,7 +479,7 @@ static void mdbox_rebuild_get_header(struct mail_index_view *view, uint32_t hdr_ext_id, - struct mdbox_index_header *hdr_r) + struct mdbox_index_header *hdr_r, bool *need_resize_r) { const void *data; size_t data_size; @@ -487,6 +487,7 @@ mail_index_get_header_ext(view, hdr_ext_id, &data, &data_size); memset(hdr_r, 0, sizeof(*hdr_r)); memcpy(hdr_r, data, I_MIN(data_size, sizeof(*hdr_r))); + *need_resize_r = data_size < sizeof(*hdr_r); } static void mdbox_header_update(struct mdbox_storage_rebuild_context *ctx, @@ -494,13 +495,17 @@ struct mdbox_mailbox *mbox) { struct mdbox_index_header hdr, backup_hdr; + bool need_resize, need_resize_backup; - mdbox_rebuild_get_header(rebuild_ctx->view, mbox->hdr_ext_id, &hdr); - if (rebuild_ctx->backup_view == NULL) + mdbox_rebuild_get_header(rebuild_ctx->view, mbox->hdr_ext_id, + &hdr, &need_resize); + if (rebuild_ctx->backup_view == NULL) { memset(&backup_hdr, 0, sizeof(backup_hdr)); - else { + need_resize = TRUE; + } else { mdbox_rebuild_get_header(rebuild_ctx->backup_view, - mbox->hdr_ext_id, &backup_hdr); + mbox->hdr_ext_id, &backup_hdr, + &need_resize_backup); } /* make sure we have valid mailbox guid */ @@ -522,6 +527,10 @@ hdr.flags |= DBOX_INDEX_HEADER_FLAG_HAVE_POP3_ORDERS; /* and write changes */ + if (need_resize) { + mail_index_ext_resize_hdr(rebuild_ctx->trans, mbox->hdr_ext_id, + sizeof(hdr)); + } mail_index_update_header_ext(rebuild_ctx->trans, mbox->hdr_ext_id, 0, &hdr, sizeof(hdr)); }