Skip to content

Commit

Permalink
lib-storage: Preserve messages' vsize record when rebuilding index
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sirainen authored and villesavolainen committed Sep 12, 2017
1 parent 575dc51 commit 2dceda4
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/lib-storage/index/index-rebuild.c
Expand Up @@ -8,6 +8,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,
Expand Down Expand Up @@ -70,6 +86,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);
}

Expand Down

0 comments on commit 2dceda4

Please sign in to comment.