From: Timo Sirainen Date: Tue, 16 Mar 2021 17:02:06 +0000 (+0200) Subject: mdbox: Split off mdbox_storage_rebuild_scan_prepare() X-Git-Tag: 2.3.18~345 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1a30dc1b434fde419992b38d107e6fdaaa119df9;p=thirdparty%2Fdovecot%2Fcore.git mdbox: Split off mdbox_storage_rebuild_scan_prepare() --- diff --git a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c index e2e115448e..ba7a0c228d 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c @@ -901,7 +901,8 @@ mdbox_storage_rebuild_scan_dir(struct mdbox_storage_rebuild_context *ctx, return ret; } -static int mdbox_storage_rebuild_scan(struct mdbox_storage_rebuild_context *ctx) +static int +mdbox_storage_rebuild_scan_prepare(struct mdbox_storage_rebuild_context *ctx) { const void *data; size_t data_size; @@ -937,7 +938,11 @@ static int mdbox_storage_rebuild_scan(struct mdbox_storage_rebuild_context *ctx) /* storage was already rebuilt by someone else */ return 0; } + return 1; +} +static int mdbox_storage_rebuild_scan(struct mdbox_storage_rebuild_context *ctx) +{ i_warning("mdbox %s: rebuilding indexes", ctx->storage->storage_dir); if (mdbox_storage_rebuild_scan_dir(ctx, ctx->storage->storage_dir, @@ -973,7 +978,8 @@ int mdbox_storage_rebuild_in_context(struct mdbox_storage *storage, } ctx = mdbox_storage_rebuild_init(storage, atomic); - ret = mdbox_storage_rebuild_scan(ctx); + if ((ret = mdbox_storage_rebuild_scan_prepare(ctx)) > 0) + ret = mdbox_storage_rebuild_scan(ctx); mdbox_storage_rebuild_deinit(ctx); if (ret == 0) {