[dovecot-cvs] dovecot/src/plugins/fts fts-api-private.h, 1.5, 1.6 fts-api.c, 1.6, 1.7 fts-api.h, 1.5, 1.6 fts-storage.c, 1.8, 1.9

tss at dovecot.org tss at dovecot.org
Fri Dec 1 20:55:58 UTC 2006


Update of /var/lib/cvs/dovecot/src/plugins/fts
In directory talvi:/tmp/cvs-serv10244/fts

Modified Files:
	fts-api-private.h fts-api.c fts-api.h fts-storage.c 
Log Message:
Added fts_backend_expunge_finish() virtual backend function.



Index: fts-api-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts/fts-api-private.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- fts-api-private.h	25 Oct 2006 20:24:55 -0000	1.5
+++ fts-api-private.h	1 Dec 2006 20:55:55 -0000	1.6
@@ -17,6 +17,8 @@
 	int (*build_deinit)(struct fts_backend_build_context *ctx);
 
 	void (*expunge)(struct fts_backend *backend, struct mail *mail);
+	void (*expunge_finish)(struct fts_backend *backend,
+			       struct mailbox *box, bool committed);
 
 	int (*lookup)(struct fts_backend *backend, const char *key,
 		      ARRAY_TYPE(seq_range) *result);

Index: fts-api.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts/fts-api.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- fts-api.c	25 Oct 2006 20:24:55 -0000	1.6
+++ fts-api.c	1 Dec 2006 20:55:55 -0000	1.7
@@ -82,6 +82,12 @@
 	backend->v.expunge(backend, mail);
 }
 
+void fts_backend_expunge_finish(struct fts_backend *backend,
+				struct mailbox *box, bool committed)
+{
+	backend->v.expunge_finish(backend, box, committed);
+}
+
 int fts_backend_lookup(struct fts_backend *backend, const char *key,
 		       ARRAY_TYPE(seq_range) *result)
 {

Index: fts-api.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts/fts-api.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- fts-api.h	25 Oct 2006 20:24:55 -0000	1.5
+++ fts-api.h	1 Dec 2006 20:55:55 -0000	1.6
@@ -25,8 +25,12 @@
 /* Finish adding new data to the index. */
 int fts_backend_build_deinit(struct fts_backend_build_context *ctx);
 
-/* Expunge given mail from the backend. */
+/* Expunge given mail from the backend. Note that the transaction may still
+   fail later. */
 void fts_backend_expunge(struct fts_backend *backend, struct mail *mail);
+/* Called after transaction has been committed or rollbacked. */
+void fts_backend_expunge_finish(struct fts_backend *backend,
+				struct mailbox *box, bool committed);
 
 /* Lookup key from the index and return the found UIDs in result. */
 int fts_backend_lookup(struct fts_backend *backend, const char *key,

Index: fts-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts/fts-storage.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- fts-storage.c	25 Oct 2006 20:24:55 -0000	1.8
+++ fts-storage.c	1 Dec 2006 20:55:55 -0000	1.9
@@ -27,6 +27,10 @@
 	unsigned int result_pos;
 };
 
+struct fts_transaction_context {
+	bool expunges;
+};
+
 struct fts_mail {
 	struct mail_vfuncs super;
 };
@@ -394,6 +398,7 @@
 	       struct mailbox_header_lookup_ctx *wanted_headers)
 {
 	struct fts_mailbox *fbox = FTS_CONTEXT(t->box);
+	struct fts_transaction_context *ft = FTS_CONTEXT(t);
 	struct fts_mail *fmail;
 	struct mail *_mail;
 	struct mail_private *mail;
@@ -401,6 +406,8 @@
 	_mail = fbox->super.mail_alloc(t, wanted_fields, wanted_headers);
 	mail = (struct mail_private *)_mail;
 
+	ft->expunges = TRUE;
+
 	fmail = p_new(mail->pool, struct fts_mail, 1);
 	fmail->super = mail->v;
 
@@ -409,6 +416,48 @@
 	return _mail;
 }
 
+static struct mailbox_transaction_context *
+fts_transaction_begin(struct mailbox *box,
+		      enum mailbox_transaction_flags flags)
+{
+	struct fts_mailbox *fbox = FTS_CONTEXT(box);
+	struct mailbox_transaction_context *t;
+	struct fts_transaction_context *ft;
+
+	ft = i_new(struct fts_transaction_context, 1);
+
+	t = fbox->super.transaction_begin(box, flags);
+	array_idx_set(&t->module_contexts, fts_storage_module_id, &ft);
+	return t;
+}
+
+static void fts_transaction_rollback(struct mailbox_transaction_context *t)
+{
+	struct mailbox *box = t->box;
+	struct fts_mailbox *fbox = FTS_CONTEXT(box);
+	struct fts_transaction_context *ft = FTS_CONTEXT(t);
+
+	fbox->super.transaction_rollback(t);
+	if (ft->expunges)
+		fts_backend_expunge_finish(fbox->backend, box, FALSE);
+	i_free(ft);
+}
+
+static int fts_transaction_commit(struct mailbox_transaction_context *t,
+				  enum mailbox_sync_flags flags)
+{
+	struct mailbox *box = t->box;
+	struct fts_mailbox *fbox = FTS_CONTEXT(box);
+	struct fts_transaction_context *ft = FTS_CONTEXT(t);
+	int ret;
+
+	ret = fbox->super.transaction_commit(t, flags);
+	if (ft->expunges)
+		fts_backend_expunge_finish(fbox->backend, box, ret == 0);
+	i_free(ft);
+	return ret;
+}
+
 void fts_mailbox_opened(struct mailbox *box)
 {
 	struct fts_mailbox *fbox;
@@ -434,6 +483,9 @@
 	box->v.search_next_update_seq = fts_mailbox_search_next_update_seq;
 	box->v.search_deinit = fts_mailbox_search_deinit;
 	box->v.mail_alloc = fts_mail_alloc;
+	box->v.transaction_begin = fts_transaction_begin;
+	box->v.transaction_rollback = fts_transaction_rollback;
+	box->v.transaction_commit = fts_transaction_commit;
 
 	if (!fts_storage_module_id_set) {
 		fts_storage_module_id = mail_storage_module_id++;



More information about the dovecot-cvs mailing list