mail-cache-sync-update.c revision 0f20dd043770d8c4460e5cfc2e8741e58c949ab6
40c5626383ebd5e8cf11a636f864023a2aafcd6bDaniel Couto Vale/* Copyright (C) 2004 Timo Sirainen */
58721b9d3a8cd6a624269ddf507f80af4417c9bdhenning muellerstatic void mail_cache_handler_deinit(struct mail_index_sync_map_ctx *sync_ctx,
58721b9d3a8cd6a624269ddf507f80af4417c9bdhenning mueller (void)mail_cache_unlock(sync_ctx->view->index->cache);
75c2a995e5c564f96cf5559145e59f89d6435ee1Tim Reddehasestatic int mail_cache_handler_init(struct mail_cache_sync_context **ctx_r,
2e7a48951591a6eeda9a3ab4e14cd13012cb43eaJulian Kornberger struct mail_cache_sync_context *ctx = *ctx_r;
58721b9d3a8cd6a624269ddf507f80af4417c9bdhenning mueller ctx = *ctx_r = i_new(struct mail_cache_sync_context, 1);
40c5626383ebd5e8cf11a636f864023a2aafcd6bDaniel Couto Valestatic int get_cache_file_seq(struct mail_index_view *view,
d1860f0434d6460259d04f8952e55df38fe517f7Tim Reddehase ext = mail_index_view_get_ext(view, view->index->cache->ext_id);
d1860f0434d6460259d04f8952e55df38fe517f7Tim Reddehaseint mail_cache_expunge_handler(struct mail_index_sync_map_ctx *sync_ctx,
75c2a995e5c564f96cf5559145e59f89d6435ee1Tim Reddehase uint32_t seq __attr_unused__, const void *data,
71fdc30cc6e637d99cacb455537e7b8fbfe77395henning mueller struct mail_cache_sync_context *ctx = *sync_context;
75c2a995e5c564f96cf5559145e59f89d6435ee1Tim Reddehase if (!get_cache_file_seq(sync_ctx->view, &cache_file_seq))
75c2a995e5c564f96cf5559145e59f89d6435ee1Tim Reddehase (void)mail_cache_delete(cache, *cache_offset);
2977875e15fdb6d84be990579c61cda0b6cbb5d0Tim Reddehaseint mail_cache_sync_handler(struct mail_index_sync_map_ctx *sync_ctx,
2977875e15fdb6d84be990579c61cda0b6cbb5d0Tim Reddehase struct mail_index_view *view = sync_ctx->view;
2977875e15fdb6d84be990579c61cda0b6cbb5d0Tim Reddehase struct mail_cache *cache = view->index->cache;
2977875e15fdb6d84be990579c61cda0b6cbb5d0Tim Reddehase struct mail_cache_sync_context *ctx = *context;
609a4ff9a0e4cb89a9f529703c81554fe9c34ff6Tim Reddehase file_cache_invalidate(cache->file_cache, *new_cache_offset,
609a4ff9a0e4cb89a9f529703c81554fe9c34ff6Tim Reddehase if (*old_cache_offset == 0 || *old_cache_offset == *new_cache_offset ||
a8ab4146c3238374bdd13a36b12d665cde57e078Tim Reddehase sync_ctx->type == MAIL_INDEX_SYNC_HANDLER_VIEW)
a8ab4146c3238374bdd13a36b12d665cde57e078Tim Reddehase mail_transaction_log_view_get_prev_pos(view->log_view,
a8ab4146c3238374bdd13a36b12d665cde57e078Tim Reddehase mail_transaction_log_get_mailbox_sync_pos(view->index->log,
a8ab4146c3238374bdd13a36b12d665cde57e078Tim Reddehase if (LOG_IS_BEFORE(cur_seq, cur_offset, tail_seq, tail_offset)) {
a8ab4146c3238374bdd13a36b12d665cde57e078Tim Reddehase /* already been linked */
705933deb08bc4269e8c08d50143af3cb5c1c670henning mueller /* we'll need to link the old and new cache records */
a274d776b3371051dcdd74b598182ce113ca5135Julian Kornberger ret = mail_cache_handler_init(&ctx, cache);
aa056a2e5efb6505701a4e4a31bf2f7e71ff1738henning mueller if (!get_cache_file_seq(view, &cache_file_seq))
519002bc41b20a069be1c669660e702f9bd4a593Eugen Kuksa /* cache has been compressed, don't modify it */
2e7a48951591a6eeda9a3ab4e14cd13012cb43eaJulian Kornberger if (mail_cache_link(cache, *old_cache_offset, *new_cache_offset) < 0)
a274d776b3371051dcdd74b598182ce113ca5135Julian Kornbergervoid mail_cache_sync_lost_handler(struct mail_index *index)