bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2007-2018 Dovecot authors, see the included COPYING file */
88187ee880b4829443e0d55ea7d145d9d5880217Timo Sirainenstatic void cydir_sync_set_uidvalidity(struct cydir_sync_context *ctx)
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainen offsetof(struct mail_index_header, uid_validity),
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainenstatic string_t *cydir_get_path_prefix(struct cydir_mailbox *mbox)
feaa6a3d82ea61496ced1f83a726ff33047c7da2Timo Sirainen str_append(path, mailbox_get_path(&mbox->box));
5137d2d80255938a0f5fb8f3c1a21b34cf11ada3Timo Sirainencydir_sync_expunge(struct cydir_sync_context *ctx, uint32_t seq1, uint32_t seq2)
5137d2d80255938a0f5fb8f3c1a21b34cf11ada3Timo Sirainen ctx->path_dir_prefix_len = str_len(ctx->path);
88187ee880b4829443e0d55ea7d145d9d5880217Timo Sirainen mail_index_lookup_uid(ctx->sync_view, seq1, &uid);
5137d2d80255938a0f5fb8f3c1a21b34cf11ada3Timo Sirainen str_truncate(ctx->path, ctx->path_dir_prefix_len);
275cc4c040899c132b2acbe2fcac48ba4c1abbcfTimo Sirainen if (i_unlink_if_exists(str_c(ctx->path)) < 0) {
275cc4c040899c132b2acbe2fcac48ba4c1abbcfTimo Sirainen /* continue anyway */
b08b33d1f5ce3721dc2d83586c9cb0ca141331fdTimo Sirainenstatic void cydir_sync_index(struct cydir_sync_context *ctx)
1d3f7c1278168d5b1cbfa9a2cc9929a0909056b4Timo Sirainen /* mark the newly seen messages as recent */
3da614c39dd29f536c485089e67839b4cf89fed3Timo Sirainen if (mail_index_lookup_seq_range(ctx->sync_view, hdr->first_recent_uid,
817d027593510c3ba70ad542ce0011f5f6916d1eTimo Sirainen mailbox_recent_flags_set_seqs(&ctx->mbox->box, ctx->sync_view,
b08b33d1f5ce3721dc2d83586c9cb0ca141331fdTimo Sirainen while (mail_index_sync_next(ctx->index_sync_ctx, &sync_rec)) {
3da614c39dd29f536c485089e67839b4cf89fed3Timo Sirainen if (!mail_index_lookup_seq_range(ctx->sync_view,
5137d2d80255938a0f5fb8f3c1a21b34cf11ada3Timo Sirainen /* already expunged, nothing to do. */
5137d2d80255938a0f5fb8f3c1a21b34cf11ada3Timo Sirainen /* FIXME: should be bother calling sync_notify()? */
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainenint cydir_sync_begin(struct cydir_mailbox *mbox,
d6a1fa1d65c6d1996937802c2482c0f14dd821a7Timo Sirainen struct cydir_sync_context **ctx_r, bool force)
3f91e60401495a4046c73992fabaa5e77200a451Timo Sirainen sync_flags = index_storage_get_sync_flags(&mbox->box) |
d6a1fa1d65c6d1996937802c2482c0f14dd821a7Timo Sirainen sync_flags |= MAIL_INDEX_SYNC_FLAG_REQUIRE_CHANGES;
9963bef626fd9ea227fb606e8b1694cdb1ab39aaTimo Sirainen ret = index_storage_expunged_sync_begin(&mbox->box, &ctx->index_sync_ctx,
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainenint cydir_sync_finish(struct cydir_sync_context **_ctx, bool success)
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainen if (mail_index_sync_commit(&ctx->index_sync_ctx) < 0) {
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainen mail_index_sync_rollback(&ctx->index_sync_ctx);
26af8fb913367d40a821d8713980cb1731ad6fcbTimo Sirainenstatic int cydir_sync(struct cydir_mailbox *mbox)
d6a1fa1d65c6d1996937802c2482c0f14dd821a7Timo Sirainen if (cydir_sync_begin(mbox, &sync_ctx, FALSE) < 0)
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainencydir_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags)
a97fdf205b182250b0fe56c0f6f418bc22fb09a3Josef 'Jeff' Sipek struct cydir_mailbox *mbox = CYDIR_MAILBOX(box);
e098ac1cd4ff0afb33b22cc7fd288014f4fdb0bcTimo Sirainen if (index_mailbox_want_full_sync(&mbox->box, flags))