{
struct mailbox *box = ctx->box;
struct fts_mailbox *fbox = FTS_CONTEXT(box);
- bool precache;
+ struct fts_mailbox_list *flist = FTS_LIST_CONTEXT(box->list);
+ bool precache, force_resync;
precache = (ctx->flags & MAILBOX_SYNC_FLAG_PRECACHE) != 0;
+ force_resync = (ctx->flags & MAILBOX_SYNC_FLAG_FORCE_RESYNC) != 0;
if (fbox->module_ctx.super.sync_deinit(ctx, status_r) < 0)
return -1;
ctx = NULL;
+ if (force_resync) {
+ if (fts_backend_optimize(flist->backend) < 0) {
+ mail_storage_set_critical(box->storage,
+ "FTS optimize for mailbox %s failed",
+ box->vname);
+ }
+ }
if (precache) {
if (fts_update(box) < 0) {
mail_storage_set_critical(box->storage,