changeset 21428:d64bd3f11bdf

lib-index: Add mail_cache_decisions_copy This allows priming cache decisions for a folder.
author Aki Tuomi <aki.tuomi@dovecot.fi>
date Tue, 27 Dec 2016 09:44:52 +0200
parents 658d7731b125
children 64625a782e87
files src/lib-index/mail-cache-decisions.c src/lib-index/mail-cache.h
diffstat 2 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-cache-decisions.c	Tue Jan 03 12:50:58 2017 +0200
+++ b/src/lib-index/mail-cache-decisions.c	Tue Dec 27 09:44:52 2016 +0200
@@ -151,3 +151,26 @@
 	mail_index_lookup_uid(view->view, seq, &uid);
 	cache->fields[field].uid_highwater = uid;
 }
+
+void mail_cache_decisions_copy(struct mail_index_transaction *itrans,
+			       struct mail_cache *src,
+			       struct mail_cache *dst)
+{
+	struct mail_cache_compress_lock *lock = NULL;
+
+	if (mail_cache_open_and_verify(src) < 0 ||
+	    MAIL_CACHE_IS_UNUSABLE(src))
+		return;
+
+	unsigned int count = 0;
+	struct mail_cache_field *fields =
+		mail_cache_register_get_list(src, pool_datastack_create(), &count);
+	i_assert(fields != NULL || count == 0);
+	if (count > 0)
+		mail_cache_register_fields(dst, fields, count);
+
+	dst->field_header_write_pending = TRUE;
+	(void)mail_cache_compress(dst, itrans, &lock);
+	if (lock != NULL)
+		mail_cache_compress_unlock(&lock);
+}
--- a/src/lib-index/mail-cache.h	Tue Jan 03 12:50:58 2017 +0200
+++ b/src/lib-index/mail-cache.h	Tue Dec 27 09:44:52 2016 +0200
@@ -88,6 +88,11 @@
 void mail_cache_view_update_cache_decisions(struct mail_cache_view *view,
 					    bool update);
 
+/* Copy caching decisions */
+void mail_cache_decisions_copy(struct mail_index_transaction *itrans,
+			       struct mail_cache *src,
+			       struct mail_cache *dst);
+
 /* Get index transaction specific cache transaction. */
 struct mail_cache_transaction_ctx *
 mail_cache_get_transaction(struct mail_cache_view *view,