/* Returns 1 = ok, 0 = no private indexes, -1 = error */
int index_mailbox_sync_pvt_init(struct mailbox *box, bool lock,
- enum mail_index_view_sync_flags flags,
struct index_mailbox_sync_pvt_context **ctx_r);
int index_mailbox_sync_pvt_newmails(struct index_mailbox_sync_pvt_context *ctx,
struct mailbox_transaction_context *trans);
struct mail_index_view *view_pvt;
struct mail_index_transaction *trans_pvt;
struct mail_index_view *view_shared;
-
- enum mail_index_view_sync_flags flags;
};
static int sync_pvt_expunges(struct index_mailbox_sync_pvt_context *ctx)
}
int index_mailbox_sync_pvt_init(struct mailbox *box, bool lock,
- enum mail_index_view_sync_flags flags,
struct index_mailbox_sync_pvt_context **ctx_r)
{
struct index_mailbox_sync_pvt_context *ctx;
ctx = i_new(struct index_mailbox_sync_pvt_context, 1);
ctx->box = box;
- ctx->flags = flags;
if (lock) {
if (index_mailbox_sync_open(ctx, TRUE) < 0) {
index_mailbox_sync_pvt_deinit(&ctx);
if (index_mailbox_sync_pvt_index(ctx, NULL, 0) < 0)
return -1;
- /* sync the private view */
- view_sync_ctx = mail_index_view_sync_begin(ctx->box->view_pvt, ctx->flags);
+ /* Sync the private view. The flags index can't be fully synced with
+ the main index at all times anyway, so don't even try. Just fully
+ sync it always and fix any found inconsistencies. This way we also
+ avoid any unnecessary "dovecot.index.pvt reset, view is now
+ inconsistent" errors. */
+ view_sync_ctx = mail_index_view_sync_begin(ctx->box->view_pvt,
+ MAIL_INDEX_VIEW_SYNC_FLAG_FIX_INCONSISTENT);
while (mail_index_view_sync_next(view_sync_ctx, &sync_rec)) {
if (sync_rec.type != MAIL_INDEX_VIEW_SYNC_TYPE_FLAGS)
continue;
doesn't matter if it's called at _sync_init() or _sync_deinit().
however we also need to know if any private flags have changed
since last sync, so we need to call it before _sync_next() calls. */
- if (index_mailbox_sync_pvt_init(box, FALSE, sync_flags, &pvt_ctx) > 0) {
+ if (index_mailbox_sync_pvt_init(box, FALSE, &pvt_ctx) > 0) {
(void)index_mailbox_sync_pvt_view(pvt_ctx, &ctx->flag_updates,
&ctx->hidden_updates);
index_mailbox_sync_pvt_deinit(&pvt_ctx);