int mdbox_map_refresh(struct mdbox_map *map)
{
struct mail_index_view_sync_ctx *ctx;
- bool delayed_expunges;
+ bool delayed_expunges, fscked;
+ int ret = 0;
/* some open files may have read partially written mails. now that
map syncing makes the new mails visible, we need to make sure the
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);
+ fscked = mail_index_reset_fscked(map->view->index);
if (mail_index_view_sync_commit(&ctx, &delayed_expunges) < 0) {
mail_storage_set_internal_error(MAP_STORAGE(map));
mail_index_reset_error(map->index);
- return -1;
+ ret = -1;
}
- return 0;
+ if (fscked)
+ mdbox_storage_set_corrupted(map->storage);
+ return ret;
}
static void
if (mdbox_map_atomic_lock(ctx->atomic) < 0)
return -1;
+ /* fsck the map just in case its UIDs are broken */
+ if (mail_index_fsck(ctx->storage->map->index) < 0) {
+ mail_storage_set_internal_error(&ctx->storage->storage.storage);
+ return -1;
+ }
+
/* get old map header */
mail_index_get_header_ext(ctx->atomic->sync_view,
ctx->storage->map->map_ext_id,