From: Timo Sirainen Date: Thu, 5 May 2011 15:48:55 +0000 (+0200) Subject: lib-storage: Added mail_is_cached() X-Git-Tag: 2.0.13~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7370fb9ff75b674f99059adf24502ee9ae7a47bc;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Added mail_is_cached() --- diff --git a/src/lib-storage/index/index-transaction.c b/src/lib-storage/index/index-transaction.c index 11f5ccd3b2..28875de117 100644 --- a/src/lib-storage/index/index-transaction.c +++ b/src/lib-storage/index/index-transaction.c @@ -88,6 +88,9 @@ void index_transaction_init(struct index_transaction_context *it, 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; diff --git a/src/lib-storage/mail-storage-private.h b/src/lib-storage/mail-storage-private.h index f2d7babaab..e1c7da52cf 100644 --- a/src/lib-storage/mail-storage-private.h +++ b/src/lib-storage/mail-storage-private.h @@ -390,6 +390,9 @@ struct mailbox_transaction_context { /* 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 *); diff --git a/src/lib-storage/mail-storage.h b/src/lib-storage/mail-storage.h index 32c9bc4cdf..0c88dfb256 100644 --- a/src/lib-storage/mail-storage.h +++ b/src/lib-storage/mail-storage.h @@ -701,6 +701,9 @@ void mail_update_modseq(struct mail *mail, uint64_t min_modseq); 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); diff --git a/src/lib-storage/mail.c b/src/lib-storage/mail.c index 6b602302a5..50faf5a7d3 100644 --- a/src/lib-storage/mail.c +++ b/src/lib-storage/mail.c @@ -7,6 +7,7 @@ #include "crc32.h" #include "sha1.h" #include "hostpid.h" +#include "mail-cache.h" #include "mail-storage-private.h" #include @@ -239,6 +240,12 @@ void mail_set_expunged(struct mail *mail) 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;