Skip to content

Commit

Permalink
lib-index: Add mail_cache_decisions_copy
Browse files Browse the repository at this point in the history
This allows priming cache decisions for a folder.
  • Loading branch information
cmouse authored and sirainen committed Jan 24, 2017
1 parent 349ad03 commit 21149ee
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/lib-index/mail-cache-decisions.c
Expand Up @@ -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);
}
5 changes: 5 additions & 0 deletions src/lib-index/mail-cache.h
Expand Up @@ -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,
Expand Down

0 comments on commit 21149ee

Please sign in to comment.