Mercurial > dovecot > core-2.2
changeset 12994:55ff92050bd7
lib-storage: Added mail_is_cached()
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 05 May 2011 17:48:55 +0200 |
parents | 45f6d523b1a1 |
children | e9918fd289f3 |
files | src/lib-storage/index/index-transaction.c src/lib-storage/mail-storage-private.h src/lib-storage/mail-storage.h src/lib-storage/mail.c |
diffstat | 4 files changed, 16 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/index-transaction.c Thu May 05 17:47:58 2011 +0200 +++ b/src/lib-storage/index/index-transaction.c Thu May 05 17:48:55 2011 +0200 @@ -88,6 +88,9 @@ it->cache_view = mail_cache_view_open(box->cache, t->view); it->cache_trans = mail_cache_get_transaction(it->cache_view, t->itrans); + t->cache_view = it->cache_view; + t->cache_trans = it->cache_trans; + /* set up after mail_cache_get_transaction(), so that we'll still have the cache_trans available in _index_commit() */ it->super = t->itrans->v;
--- a/src/lib-storage/mail-storage-private.h Thu May 05 17:47:58 2011 +0200 +++ b/src/lib-storage/mail-storage-private.h Thu May 05 17:48:55 2011 +0200 @@ -390,6 +390,9 @@ /* view contains all changes done within this transaction */ struct mail_index_view *view; + struct mail_cache_view *cache_view; + struct mail_cache_transaction_ctx *cache_trans; + struct mail_transaction_commit_changes *changes; ARRAY_DEFINE(module_contexts, union mailbox_transaction_module_context *);
--- a/src/lib-storage/mail-storage.h Thu May 05 17:47:58 2011 +0200 +++ b/src/lib-storage/mail-storage.h Thu May 05 17:48:55 2011 +0200 @@ -701,6 +701,9 @@ void mail_update_pop3_uidl(struct mail *mail, const char *uidl); /* Expunge this message. Sequence numbers don't change until commit. */ void mail_expunge(struct mail *mail); + +/* Returns TRUE if anything is cached for the mail, FALSE if not. */ +bool mail_is_cached(struct mail *mail); /* Mark a cached field corrupted and have it recalculated. */ void mail_set_cache_corrupted(struct mail *mail, enum mail_fetch_field field);
--- a/src/lib-storage/mail.c Thu May 05 17:47:58 2011 +0200 +++ b/src/lib-storage/mail.c Thu May 05 17:48:55 2011 +0200 @@ -7,6 +7,7 @@ #include "crc32.h" #include "sha1.h" #include "hostpid.h" +#include "mail-cache.h" #include "mail-storage-private.h" #include <time.h> @@ -239,6 +240,12 @@ mail->expunged = TRUE; } +bool mail_is_cached(struct mail *mail) +{ + return mail_cache_field_exists_any(mail->transaction->cache_view, + mail->seq); +} + void mail_set_cache_corrupted(struct mail *mail, enum mail_fetch_field field) { struct mail_private *p = (struct mail_private *)mail;