From a594a595488241e2228d40b224d3e123258b9d68 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Fri, 8 Sep 2017 12:20:21 +0300 Subject: [PATCH] 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. --- src/lib-storage/index/index-rebuild.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/lib-storage/index/index-rebuild.c b/src/lib-storage/index/index-rebuild.c index 6533f061d7..ef234eab20 100644 --- a/src/lib-storage/index/index-rebuild.c +++ b/src/lib-storage/index/index-rebuild.c @@ -9,6 +9,22 @@ #include "index-storage.h" #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, @@ -71,6 +87,7 @@ index_index_copy_from_old(struct index_rebuild_context *ctx, 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); } -- 2.47.3