[dovecot-cvs] dovecot/src/lib-index mail-cache-transaction.c, 1.49, 1.50 mail-cache.h, 1.26, 1.27

tss-movial at dovecot.org tss-movial at dovecot.org
Mon May 8 15:48:53 EEST 2006


Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv11649

Modified Files:
	mail-cache-transaction.c mail-cache.h 
Log Message:
Added mail_cache_field_want_add() and mail_cache_field_can_add()


Index: mail-cache-transaction.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-transaction.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- mail-cache-transaction.c	28 Jan 2006 21:10:41 -0000	1.49
+++ mail-cache-transaction.c	8 May 2006 12:48:51 -0000	1.50
@@ -747,6 +747,30 @@
                 buffer_append_zero(ctx->cache_data, 4 - (data_size & 3));
 }
 
+bool mail_cache_field_want_add(struct mail_cache_transaction_ctx *ctx,
+			       uint32_t seq, unsigned int field)
+{
+	enum mail_cache_decision_type decision;
+
+	decision = mail_cache_field_get_decision(ctx->view->cache, field);
+	if ((decision & ~MAIL_CACHE_DECISION_FORCED) == MAIL_CACHE_DECISION_NO)
+		return FALSE;
+
+	return mail_cache_field_exists(ctx->view, seq, field) == 0;
+}
+
+bool mail_cache_field_can_add(struct mail_cache_transaction_ctx *ctx,
+			      uint32_t seq, unsigned int field)
+{
+	enum mail_cache_decision_type decision;
+
+	decision = mail_cache_field_get_decision(ctx->view->cache, field);
+	if (decision == (MAIL_CACHE_DECISION_FORCED | MAIL_CACHE_DECISION_NO))
+		return FALSE;
+
+	return mail_cache_field_exists(ctx->view, seq, field) == 0;
+}
+
 static int mail_cache_link_unlocked(struct mail_cache *cache,
 				    uint32_t old_offset, uint32_t new_offset)
 {

Index: mail-cache.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- mail-cache.h	14 Jan 2006 18:47:34 -0000	1.26
+++ mail-cache.h	8 May 2006 12:48:51 -0000	1.27
@@ -72,6 +72,15 @@
    must be exactly the expected size. */
 void mail_cache_add(struct mail_cache_transaction_ctx *ctx, uint32_t seq,
 		    unsigned int field, const void *data, size_t data_size);
+/* Returns TRUE if field is wanted to be added and it doesn't already exist.
+   If current caching decisions say not to cache this field, FALSE is returned.
+   If seq is 0, the existence isn't checked. */
+bool mail_cache_field_want_add(struct mail_cache_transaction_ctx *ctx,
+			       uint32_t seq, unsigned int field);
+/* Like mail_cache_field_want_add(), but in caching decisions FALSE is
+   returned only if the decision is a forced no. */
+bool mail_cache_field_can_add(struct mail_cache_transaction_ctx *ctx,
+			      uint32_t seq, unsigned int field);
 
 /* Retursn 1 if field exists, 0 if not, -1 if error. */
 int mail_cache_field_exists(struct mail_cache_view *view, uint32_t seq,



More information about the dovecot-cvs mailing list