]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Add mail_cache_decisions_copy
authorAki Tuomi <aki.tuomi@dovecot.fi>
Tue, 27 Dec 2016 07:44:52 +0000 (09:44 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 24 Jan 2017 09:35:00 +0000 (11:35 +0200)
This allows priming cache decisions for a folder.

src/lib-index/mail-cache-decisions.c
src/lib-index/mail-cache.h

index fa88198486b3ae22261e3f75750172bf5d6c6e77..02bc4790b968e992dd3769b3ea8e477c1d222323 100644 (file)
@@ -151,3 +151,26 @@ void mail_cache_decision_add(struct mail_cache_view *view, uint32_t seq,
        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);
+}
index 3a9cbc521d4b9482b130327de50f27b6dbf630ac..227a4b801dc7b9904feb1e90e47769a7745aaf55 100644 (file)
@@ -88,6 +88,11 @@ void mail_cache_view_close(struct mail_cache_view **view);
 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,