diff --git a/src/lib-index/mail-cache-decisions.c b/src/lib-index/mail-cache-decisions.c index fa88198486..02bc4790b9 100644 --- a/src/lib-index/mail-cache-decisions.c +++ b/src/lib-index/mail-cache-decisions.c @@ -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); +} diff --git a/src/lib-index/mail-cache.h b/src/lib-index/mail-cache.h index 3a9cbc521d..227a4b801d 100644 --- a/src/lib-index/mail-cache.h +++ b/src/lib-index/mail-cache.h @@ -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,