sdbox-sync.c revision d0b2bd9e2246eb68ed952c7f2e13d1969d657c8f
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi/* Copyright (c) 2007-2011 Dovecot authors, see the included COPYING file */
1d980e5489836e977ba59b419e27b0ec875c4bd3takashidbox_sync_file_move_if_needed(struct dbox_file *file,
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi bool move_to_alt = type == SDBOX_SYNC_ENTRY_TYPE_MOVE_TO_ALT;
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi /* move the file. if it fails, nothing broke so
3f08db06526d6901aa08c110b5bc7dde6bc39905nd don't worry about it. */
1d980e5489836e977ba59b419e27b0ec875c4bd3takashistatic void sdbox_sync_file(struct sdbox_sync_context *ctx,
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi if (!mail_index_transaction_is_expunged(ctx->trans, seq)) {
1d980e5489836e977ba59b419e27b0ec875c4bd3takashistatic void sdbox_sync_add(struct sdbox_sync_context *ctx,
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi if (sync_rec->type == MAIL_INDEX_SYNC_TYPE_EXPUNGE) {
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi /* we're interested */
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi } else if (sync_rec->type == MAIL_INDEX_SYNC_TYPE_FLAGS) {
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi /* we care only about alt flag changes */
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi if ((sync_rec->add_flags & DBOX_INDEX_FLAG_ALT) != 0)
b2a930a0c94e9fd25f8d2b3a2c53573235db3f06nilgun else if ((sync_rec->remove_flags & DBOX_INDEX_FLAG_ALT) != 0)
b2a930a0c94e9fd25f8d2b3a2c53573235db3f06nilgun /* not interested */
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi /* already expunged everything. nothing to do. */
1d980e5489836e977ba59b419e27b0ec875c4bd3takashistatic int sdbox_sync_index(struct sdbox_sync_context *ctx)
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi /* newly created index file */
b2a930a0c94e9fd25f8d2b3a2c53573235db3f06nilgun "sdbox %s: Broken index: missing UIDVALIDITY",
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi /* mark the newly seen messages as recent */
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi if (mail_index_lookup_seq_range(ctx->sync_view, hdr->first_recent_uid,
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi index_mailbox_set_recent_seq(box, ctx->sync_view, seq1, seq2);
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi while (mail_index_sync_next(ctx->index_sync_ctx, &sync_rec))
1d980e5489836e977ba59b419e27b0ec875c4bd3takashistatic void dbox_sync_file_expunge(struct sdbox_sync_context *ctx,
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi /* do sync_notify only when the file was unlinked by us */
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi box->v.sync_notify(box, uid, MAILBOX_SYNC_TYPE_EXPUNGE);
1d980e5489836e977ba59b419e27b0ec875c4bd3takashistatic void dbox_sync_expunge_files(struct sdbox_sync_context *ctx)
b2a930a0c94e9fd25f8d2b3a2c53573235db3f06nilgun /* NOTE: Index is no longer locked. Multiple processes may be unlinking
b2a930a0c94e9fd25f8d2b3a2c53573235db3f06nilgun the files at the same time. */
b2a930a0c94e9fd25f8d2b3a2c53573235db3f06nilgunsdbox_refresh_header(struct sdbox_mailbox *mbox, bool retry, bool log_error)
b2a930a0c94e9fd25f8d2b3a2c53573235db3f06nilgunint sdbox_sync_begin(struct sdbox_mailbox *mbox, enum sdbox_sync_flags flags,
11495c9f0bd33e51a25b4d532beadfbcf9b944a3nilgun unsigned int i;
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi force_rebuild = (flags & SDBOX_SYNC_FLAG_FORCE_REBUILD) != 0;
if (ret <= 0) {
if (ret < 0)
return ret;
if (rebuild)
ret = 0;
if (ret == 0) {
if (i >= SDBOX_REBUILD_COUNT) {
if (ret < 0) {
if (success) {
return ret;
struct mailbox_sync_context *
int ret = 0;