mail-cache-sync-update.c revision 45312f52ff3a3d4c137447be4c7556500c2f8bf2
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidek/* Copyright (c) 2004-2009 Dovecot authors, see the included COPYING file */
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidekstatic void mail_cache_handler_deinit(struct mail_index_sync_map_ctx *sync_ctx,
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidek (void)mail_cache_unlock(sync_ctx->view->index->cache);
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidekstatic struct mail_cache_sync_context *mail_cache_handler_init(void **context)
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidek *context = i_new(struct mail_cache_sync_context, 1);
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidekstatic int mail_cache_handler_lock(struct mail_cache_sync_context *ctx,
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidek if ((ret = mail_cache_lock(cache, TRUE)) <= 0) {
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidekstatic bool get_cache_file_seq(struct mail_index_view *view,
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidek ext = mail_index_view_get_ext(view, view->index->cache->ext_id);
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidekint mail_cache_expunge_handler(struct mail_index_sync_map_ctx *sync_ctx,
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidek struct mail_cache_sync_context *ctx = *sync_context;
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidek if (!get_cache_file_seq(sync_ctx->view, &cache_file_seq))
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidekint mail_cache_sync_handler(struct mail_index_sync_map_ctx *sync_ctx,
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidek struct mail_cache_sync_context *ctx = *context;
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidek if (cache->file_cache != NULL && !MAIL_CACHE_IS_UNUSABLE(cache)) {
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidek /* flush read cache only once per sync */
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidek if (!ctx->nfs_read_cache_flushed && cache->index->nfs_flush) {
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidek /* don't invalidate anything that's already been invalidated
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidek within this sync. */
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidek if (*new_cache_offset < ctx->invalidate_highwater) {
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidek if (*old_cache_offset == 0 || *old_cache_offset == *new_cache_offset ||
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidek sync_ctx->type == MAIL_INDEX_SYNC_HANDLER_VIEW)
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidek mail_transaction_log_view_get_prev_pos(view->log_view,
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidek mail_transaction_log_get_mailbox_sync_pos(view->index->log,
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidek if (LOG_IS_BEFORE(cur_seq, cur_offset, tail_seq, tail_offset)) {
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidek /* already been linked */
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidek /* we'll need to link the old and new cache records */
2d6836a90bd326391782a5753f70e8ba666b5defJan Cholasta if (!get_cache_file_seq(view, &cache_file_seq))
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidek /* cache has been compressed, don't modify it */
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidek if (mail_cache_link(cache, *old_cache_offset, *new_cache_offset) < 0)
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidekvoid mail_cache_sync_lost_handler(struct mail_index *index)
25f8fac2489fd209d603acb2b494f7c72968e9bbMichal Zidek mail_index_flush_read_cache(cache->index, cache->filepath,