changeset 13471:efedf0644da8

lib-index: Added mail_cache_view_update_cache_decisions()
author Timo Sirainen <tss@iki.fi>
date Tue, 30 Aug 2011 04:31:00 +0300
parents e01c9f89b0b0
children 5320315600a4
files src/lib-index/mail-cache-decisions.c src/lib-index/mail-cache-private.h src/lib-index/mail-cache.c src/lib-index/mail-cache.h
diffstat 4 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-cache-decisions.c	Mon Aug 29 07:08:04 2011 +0300
+++ b/src/lib-index/mail-cache-decisions.c	Tue Aug 30 04:31:00 2011 +0300
@@ -79,6 +79,9 @@
 
 	i_assert(field < cache->fields_count);
 
+	if (view->no_decision_updates)
+		return;
+
 	mail_index_lookup_uid(view->view, seq, &uid);
 	hdr = mail_index_get_header(view->view);
 
@@ -124,7 +127,7 @@
 
 	i_assert(field < cache->fields_count);
 
-	if (MAIL_CACHE_IS_UNUSABLE(cache))
+	if (MAIL_CACHE_IS_UNUSABLE(cache) || view->no_decision_updates)
 		return;
 
 	if (cache->fields[field].field.decision != MAIL_CACHE_DECISION_NO) {
--- a/src/lib-index/mail-cache-private.h	Mon Aug 29 07:08:04 2011 +0300
+++ b/src/lib-index/mail-cache-private.h	Tue Aug 30 04:31:00 2011 +0300
@@ -198,6 +198,8 @@
 	buffer_t *cached_exists_buf;
 	uint8_t cached_exists_value;
 	uint32_t cached_exists_seq;
+
+	unsigned int no_decision_updates:1;
 };
 
 struct mail_cache_iterate_field {
--- a/src/lib-index/mail-cache.c	Mon Aug 29 07:08:04 2011 +0300
+++ b/src/lib-index/mail-cache.c	Tue Aug 30 04:31:00 2011 +0300
@@ -714,6 +714,12 @@
 	i_free(view);
 }
 
+void mail_cache_view_update_cache_decisions(struct mail_cache_view *view,
+					    bool update)
+{
+	view->no_decision_updates = !update;
+}
+
 uint32_t mail_cache_get_first_new_seq(struct mail_index_view *view)
 {
 	const struct mail_index_header *idx_hdr;
--- a/src/lib-index/mail-cache.h	Mon Aug 29 07:08:04 2011 +0300
+++ b/src/lib-index/mail-cache.h	Tue Aug 30 04:31:00 2011 +0300
@@ -71,6 +71,11 @@
 mail_cache_view_open(struct mail_cache *cache, struct mail_index_view *iview);
 void mail_cache_view_close(struct mail_cache_view *view);
 
+/* Normally cache decisions are updated on lookup/add. Use this function to
+   enable/disable this (useful for precaching data). */
+void mail_cache_view_update_cache_decisions(struct mail_cache_view *view,
+					    bool update);
+
 /* Get index transaction specific cache transaction. */
 struct mail_cache_transaction_ctx *
 mail_cache_get_transaction(struct mail_cache_view *view,