# HG changeset patch # User Timo Sirainen # Date 1504862421 -10800 # Node ID 01f841c0febba0cba08d62f13ac73cc06c678539 # Parent d4274c2f8468a0e86faad57b291f243774b3bebf lib-storage: Preserve messages' vsize record when rebuilding index Since vsize is often used by quota, losing this can be very expensive. If the vsize is wrong, it gets fixed automatically when fetching the message body. diff -r d4274c2f8468 -r 01f841c0febb src/lib-storage/index/index-rebuild.c --- a/src/lib-storage/index/index-rebuild.c Fri Aug 25 15:12:06 2017 +0300 +++ b/src/lib-storage/index/index-rebuild.c Fri Sep 08 12:20:21 2017 +0300 @@ -9,6 +9,22 @@ #include "index-rebuild.h" static void +index_index_copy_vsize(struct index_rebuild_context *ctx, + struct mail_index_view *view, + uint32_t old_seq, uint32_t new_seq) +{ + const void *data; + bool expunged; + + mail_index_lookup_ext(view, old_seq, ctx->box->mail_vsize_ext_id, + &data, &expunged); + if (data != NULL && !expunged) { + mail_index_update_ext(ctx->trans, new_seq, + ctx->box->mail_vsize_ext_id, data, NULL); + } +} + +static void index_index_copy_cache(struct index_rebuild_context *ctx, struct mail_index_view *view, uint32_t old_seq, uint32_t new_seq) @@ -70,6 +86,7 @@ modseq = mail_index_modseq_lookup(view, old_seq); mail_index_update_modseq(ctx->trans, new_seq, modseq); + index_index_copy_vsize(ctx, view, old_seq, new_seq); index_index_copy_cache(ctx, view, old_seq, new_seq); }