Example #1
0
struct maildir_keywords_sync_ctx *
maildir_keywords_sync_init_readonly(struct maildir_keywords *mk,
				    struct mail_index *index)
{
	struct maildir_keywords_sync_ctx *ctx;

	ctx = maildir_keywords_sync_init(mk, index);
	ctx->readonly = TRUE;
	return ctx;
}
Example #2
0
int maildir_sync_index_begin(struct maildir_mailbox *mbox,
			     struct maildir_sync_context *maildir_sync_ctx,
			     struct maildir_index_sync_context **ctx_r)
{
	struct mailbox *_box = &mbox->box;
	struct maildir_index_sync_context *ctx;
	struct mail_index_sync_ctx *sync_ctx;
	struct mail_index_view *view;
	struct mail_index_transaction *trans;
	enum mail_index_sync_flags sync_flags;

	sync_flags = index_storage_get_sync_flags(&mbox->box);
	/* don't drop recent messages if we're saving messages */
	if (maildir_sync_ctx == NULL)
		sync_flags &= ~MAIL_INDEX_SYNC_FLAG_DROP_RECENT;

	if (mail_index_sync_begin(_box->index, &sync_ctx, &view,
				  &trans, sync_flags) < 0) {
		mailbox_set_index_error(_box);
		return -1;
	}

	ctx = i_new(struct maildir_index_sync_context, 1);
	ctx->mbox = mbox;
	ctx->maildir_sync_ctx = maildir_sync_ctx;
	ctx->sync_ctx = sync_ctx;
	ctx->view = view;
	ctx->trans = trans;
	ctx->keywords_sync_ctx =
		maildir_keywords_sync_init(mbox->keywords, _box->index);
	ctx->sync_changes =
		index_sync_changes_init(ctx->sync_ctx, ctx->view, ctx->trans,
					maildir_is_backend_readonly(mbox));
	ctx->start_time = time(NULL);

	*ctx_r = ctx;
	return 0;
}