From: Timo Sirainen Date: Tue, 6 Dec 2011 23:48:03 +0000 (+0200) Subject: dbox: If index was fscked, rebuild indexes to make sure no mails got lost. X-Git-Tag: 2.1.rc2~93 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0b2bd9e2246eb68ed952c7f2e13d1969d657c8f;p=thirdparty%2Fdovecot%2Fcore.git dbox: If index was fscked, rebuild indexes to make sure no mails got lost. --- diff --git a/src/lib-storage/index/dbox-multi/mdbox-map.c b/src/lib-storage/index/dbox-multi/mdbox-map.c index ad98bea5ad..0cfd0e613e 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-map.c +++ b/src/lib-storage/index/dbox-multi/mdbox-map.c @@ -222,6 +222,8 @@ int mdbox_map_refresh(struct mdbox_map *map) ctx = mail_index_view_sync_begin(map->view, MAIL_INDEX_VIEW_SYNC_FLAG_FIX_INCONSISTENT); + if (mail_index_reset_fscked(map->view->index)) + mdbox_storage_set_corrupted(map->storage); if (mail_index_view_sync_commit(&ctx, &delayed_expunges) < 0) { mail_storage_set_internal_error(MAP_STORAGE(map)); mail_index_reset_error(map->index); @@ -473,6 +475,8 @@ int mdbox_map_atomic_lock(struct mdbox_map_atomic_context *atomic) log's head_offset = tail_offset */ ret = mail_index_sync_begin(atomic->map->index, &atomic->sync_ctx, &atomic->sync_view, &atomic->sync_trans, 0); + if (mail_index_reset_fscked(atomic->map->index)) + mdbox_storage_set_corrupted(atomic->map->storage); if (ret <= 0) { i_assert(ret != 0); mail_storage_set_internal_error(MAP_STORAGE(atomic->map)); diff --git a/src/lib-storage/index/dbox-multi/mdbox-sync.c b/src/lib-storage/index/dbox-multi/mdbox-sync.c index 97e256df23..3ce795bce4 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-sync.c +++ b/src/lib-storage/index/dbox-multi/mdbox-sync.c @@ -190,6 +190,8 @@ static int mdbox_sync_try_begin(struct mdbox_sync_context *ctx, ret = mail_index_sync_begin(mbox->box.index, &ctx->index_sync_ctx, &ctx->sync_view, &ctx->trans, sync_flags); + if (mail_index_reset_fscked(mbox->box.index)) + mdbox_storage_set_corrupted(mbox->storage); if (ret < 0) { mail_storage_set_index_error(&mbox->box); return -1; @@ -328,6 +330,8 @@ mdbox_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags) ret = -1; } + if (mail_index_reset_fscked(box->index)) + mdbox_storage_set_corrupted(mbox->storage); if (ret == 0 && (index_mailbox_want_full_sync(&mbox->box, flags) || mbox->storage->corrupted)) { if ((flags & MAILBOX_SYNC_FLAG_FORCE_RESYNC) != 0) diff --git a/src/lib-storage/index/dbox-single/sdbox-sync.c b/src/lib-storage/index/dbox-single/sdbox-sync.c index 4b4260e2c9..2649688b77 100644 --- a/src/lib-storage/index/dbox-single/sdbox-sync.c +++ b/src/lib-storage/index/dbox-single/sdbox-sync.c @@ -191,6 +191,8 @@ int sdbox_sync_begin(struct sdbox_mailbox *mbox, enum sdbox_sync_flags flags, &ctx->index_sync_ctx, &ctx->sync_view, &ctx->trans, sync_flags); + if (mail_index_reset_fscked(mbox->box.index)) + sdbox_set_mailbox_corrupted(&mbox->box); if (ret <= 0) { if (ret < 0) mail_storage_set_index_error(&mbox->box); @@ -283,7 +285,10 @@ sdbox_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags) ret = -1; } - if (ret == 0 && index_mailbox_want_full_sync(&mbox->box, flags)) { + if (mail_index_reset_fscked(box->index)) + sdbox_set_mailbox_corrupted(box); + if (ret == 0 && (index_mailbox_want_full_sync(&mbox->box, flags) || + mbox->corrupted_rebuild_count != 0)) { if ((flags & MAILBOX_SYNC_FLAG_FORCE_RESYNC) != 0) sdbox_sync_flags |= SDBOX_SYNC_FLAG_FORCE_REBUILD; ret = sdbox_sync(mbox, sdbox_sync_flags);