1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#ifndef MDBOX_SYNC_H
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#define MDBOX_SYNC_H
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstruct mailbox;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstruct mdbox_mailbox;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenenum mdbox_sync_flags {
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen MDBOX_SYNC_FLAG_FORCE = 0x01,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen MDBOX_SYNC_FLAG_FSYNC = 0x02,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen MDBOX_SYNC_FLAG_FORCE_REBUILD = 0x04,
f71c2d4e6b802bf8e622bcd5df29286262d05d5aTimo Sirainen MDBOX_SYNC_FLAG_NO_PURGE = 0x08,
f71c2d4e6b802bf8e622bcd5df29286262d05d5aTimo Sirainen MDBOX_SYNC_FLAG_NO_REBUILD = 0x10
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen};
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstruct mdbox_sync_context {
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct mdbox_mailbox *mbox;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct mail_index_sync_ctx *index_sync_ctx;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct mail_index_view *sync_view;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct mail_index_transaction *trans;
c18ff860dc22960fd37c272d929f889c7939a2c8Timo Sirainen struct mdbox_map_transaction_context *map_trans;
08a8b3de61139ba02371afc8240ac85be0e8b17cTimo Sirainen struct mdbox_map_atomic_context *atomic;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen enum mdbox_sync_flags flags;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen ARRAY_TYPE(seq_range) expunged_seqs;
62958c5eefcd7dd84717b487ca36ec3a86949eb9Timo Sirainen unsigned int expunged_count;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen};
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenint mdbox_sync_begin(struct mdbox_mailbox *mbox, enum mdbox_sync_flags flags,
08a8b3de61139ba02371afc8240ac85be0e8b17cTimo Sirainen struct mdbox_map_atomic_context *atomic,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen struct mdbox_sync_context **ctx_r);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenint mdbox_sync_finish(struct mdbox_sync_context **ctx, bool success);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenint mdbox_sync(struct mdbox_mailbox *mbox, enum mdbox_sync_flags flags);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstruct mailbox_sync_context *
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenmdbox_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen#endif