[dovecot-cvs] dovecot/src/plugins/fts fts-api.c,1.8,1.9

tss at dovecot.org tss at dovecot.org
Wed Dec 20 14:46:25 UTC 2006


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

Modified Files:
	fts-api.c 
Log Message:
Fixed filtering to work with Lucene. Generic FTS code now implements the
filtering if the backend doesn't.



Index: fts-api.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts/fts-api.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- fts-api.c	6 Dec 2006 15:45:15 -0000	1.8
+++ fts-api.c	20 Dec 2006 14:46:22 -0000	1.9
@@ -107,5 +107,35 @@
 int fts_backend_filter(struct fts_backend *backend, const char *key,
 		       ARRAY_TYPE(seq_range) *result)
 {
-	return backend->v.filter(backend, key, result);
+	ARRAY_TYPE(seq_range) tmp_result;
+	int ret;
+
+	if (backend->v.filter != NULL)
+		return backend->v.filter(backend, key, result);
+
+	/* do this ourself */
+	i_array_init(&tmp_result, 64);
+	ret = fts_backend_lookup(backend, key, &tmp_result);
+	if (ret == 0) {
+		const struct seq_range *range;
+		unsigned int i, count;
+		uint32_t next_seq = 1;
+
+		range = array_get(&tmp_result, &count);
+		for (i = 0; i < count; i++) {
+			if (next_seq != range[i].seq1) {
+				seq_range_array_remove_range(result, next_seq,
+							     range[i].seq1 - 1);
+			}
+			next_seq = range[i].seq2 + 1;
+		}
+
+		range = array_get(result, &count);
+		if (count > 0) {
+			seq_range_array_remove_range(result, next_seq,
+						     range[count-1].seq2);
+		}
+	}
+	array_free(&tmp_result);
+	return ret;
 }



More information about the dovecot-cvs mailing list