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

tss at dovecot.org tss at dovecot.org
Wed Oct 25 21:02:45 UTC 2006


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

Modified Files:
	fts-api-private.h fts-api.c fts-api.h fts-storage.c 
Log Message:
Added fts_backend_get_last_uid() which is first used to check if
build_init() needs to be called.



Index: fts-api-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts/fts-api-private.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- fts-api-private.h	24 Oct 2006 23:46:14 -0000	1.3
+++ fts-api-private.h	25 Oct 2006 20:02:42 -0000	1.4
@@ -7,6 +7,8 @@
 	struct fts_backend *(*init)(struct mailbox *box);
 	void (*deinit)(struct fts_backend *backend);
 
+	int (*get_last_uid)(struct fts_backend *backend, uint32_t *last_uid_r);
+
 	struct fts_backend_build_context *
 		(*build_init)(struct fts_backend *backend,
 			      uint32_t *last_uid_r);

Index: fts-api.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts/fts-api.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- fts-api.c	24 Oct 2006 23:46:14 -0000	1.4
+++ fts-api.c	25 Oct 2006 20:02:42 -0000	1.5
@@ -55,6 +55,11 @@
 	return backend->v.deinit(backend);
 }
 
+int fts_backend_get_last_uid(struct fts_backend *backend, uint32_t *last_uid_r)
+{
+	return backend->v.get_last_uid(backend, last_uid_r);
+}
+
 struct fts_backend_build_context *
 fts_backend_build_init(struct fts_backend *backend, uint32_t *last_uid_r)
 {

Index: fts-api.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts/fts-api.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- fts-api.h	24 Oct 2006 23:46:14 -0000	1.3
+++ fts-api.h	25 Oct 2006 20:02:43 -0000	1.4
@@ -9,6 +9,9 @@
 fts_backend_init(const char *backend_name, struct mailbox *box);
 void fts_backend_deinit(struct fts_backend *backend);
 
+/* Get the last_uid. */
+int fts_backend_get_last_uid(struct fts_backend *backend, uint32_t *last_uid_r);
+
 /* Initialize adding new data to the index. last_uid_r is set to the last UID
    that exists in the index. */
 struct fts_backend_build_context *

Index: fts-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts/fts-storage.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- fts-storage.c	24 Oct 2006 23:46:14 -0000	1.6
+++ fts-storage.c	25 Oct 2006 20:02:43 -0000	1.7
@@ -199,24 +199,40 @@
 	struct mail_search_seqset seqset;
 	struct mail_search_arg search_arg;
 	struct mail *mail;
-	uint32_t last_uid;
+	uint32_t last_uid, last_uid_locked;
 	int ret = 0;
 
-	memset(&ctx, 0, sizeof(ctx));
-	ctx.build = fts_backend_build_init(fbox->backend, &last_uid);
+	if (fts_backend_get_last_uid(fbox->backend, &last_uid) < 0)
+		return -1;
 
 	memset(&seqset, 0, sizeof(seqset));
 	if (mailbox_get_uids(t->box, last_uid+1, (uint32_t)-1,
-			     &seqset.seq1, &seqset.seq2) < 0) {
-		(void)fts_backend_build_deinit(ctx.build);
+			     &seqset.seq1, &seqset.seq2) < 0)
 		return -1;
-	}
 	if (seqset.seq1 == 0) {
 		/* no new messages */
-		(void)fts_backend_build_deinit(ctx.build);
 		return 0;
 	}
 
+	memset(&ctx, 0, sizeof(ctx));
+	ctx.build = fts_backend_build_init(fbox->backend, &last_uid_locked);
+	if (last_uid != last_uid_locked) {
+		/* changed, need to get again the sequences */
+		i_assert(last_uid < last_uid_locked);
+
+		last_uid = last_uid_locked;
+		if (mailbox_get_uids(t->box, last_uid+1, (uint32_t)-1,
+				     &seqset.seq1, &seqset.seq2) < 0) {
+			(void)fts_backend_build_deinit(ctx.build);
+			return -1;
+		}
+		if (seqset.seq1 == 0) {
+			/* no new messages */
+			(void)fts_backend_build_deinit(ctx.build);
+			return 0;
+		}
+	}
+
 	memset(&search_arg, 0, sizeof(search_arg));
 	search_arg.type = SEARCH_SEQSET;
 	search_arg.value.seqset = &seqset;



More information about the dovecot-cvs mailing list