]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Added mail_is_cached()
authorTimo Sirainen <tss@iki.fi>
Thu, 5 May 2011 15:48:55 +0000 (17:48 +0200)
committerTimo Sirainen <tss@iki.fi>
Thu, 5 May 2011 15:48:55 +0000 (17:48 +0200)
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

index 11f5ccd3b21e4a5c3ff8c1d9061513a6fdd93e9c..28875de117bc10d0c1ddff2351abbd6a11c94d48 100644 (file)
@@ -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;
index f2d7babaab24c45a2ffd6932cac4928b6213bbbf..e1c7da52cfaa1fceb5847dae916d19fd5e1d5059 100644 (file)
@@ -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 *);
index 32c9bc4cdfe13e621a52a79a2c7e511ada815603..0c88dfb256d5228a5b0517dc3f8c39eb392faa24 100644 (file)
@@ -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);
 
index 6b602302a5e4f26d3af1cf72e82d1d12e7123aba..50faf5a7d3ed92c541629f8722f8fa89bfe79a58 100644 (file)
@@ -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 @@ 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;