[dovecot-cvs] dovecot/src/plugins/fts-lucene lucene-wrapper.cc, 1.3, 1.4

tss at dovecot.org tss at dovecot.org
Wed Oct 25 01:30:35 UTC 2006


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

Modified Files:
	lucene-wrapper.cc 
Log Message:
Some fixes.



Index: lucene-wrapper.cc
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts-lucene/lucene-wrapper.cc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- lucene-wrapper.cc	24 Oct 2006 23:49:14 -0000	1.3
+++ lucene-wrapper.cc	25 Oct 2006 00:30:33 -0000	1.4
@@ -173,6 +173,9 @@
 {
 	int ret = 0;
 
+	index->last_uid = 0;
+	index->last_uid_doc_id = -1;
+
 	if (lucene_index_open_search(index) <= 0)
 		return -1;
 
@@ -185,8 +188,6 @@
 	query.add(&mailbox_query, true, false);
 	query.add(&last_uid_query, true, false);
 
-	index->last_uid = 0;
-	index->last_uid_doc_id = -1;
 	try {
 		Hits *hits = index->searcher->search(&query);
 
@@ -212,14 +213,15 @@
 			} else {
 				del_id = hits->id(i);
 			}
-			if (del_id >= 0)
-				index->reader->deleteDocument(del_id);
+			/*if (del_id >= 0)
+				index->reader->deleteDocument(del_id);*/
 		}
 		_CLDELETE(hits);
 	} catch (CLuceneError &err) {
 		i_error("lucene: last_uid search failed: %s", err.what());
 		ret = -1;
 	}
+
 	return ret;
 }
 
@@ -229,12 +231,14 @@
 
 	i_assert(index->mailbox_name != NULL);
 
+	lucene_index_close(index);
 	if (lucene_index_open(index) < 0)
 		return -1;
 
-	if (index->reader == NULL)
+	if (index->reader == NULL) {
 		index->last_uid = 0;
-	else {
+		index->last_uid_doc_id = -1;
+	} else {
 		if (lucene_index_get_last_uid(index) < 0)
 			return -1;
 	}
@@ -341,9 +345,16 @@
 
 	try {
 		if (index->last_uid_doc_id >= 0) {
-			index->reader->deleteDocument(index->last_uid_doc_id);
+			//index->reader->deleteDocument(index->last_uid_doc_id);
 			index->last_uid_doc_id = -1;
 		}
+	} catch (CLuceneError &err) {
+		i_error("lucene: IndexWriter::deleteDocument(%s) failed: %s",
+			index->path, err.what());
+		return -1;
+	}
+
+	try {
 		index->writer->addDocument(&doc);
 		return 0;
 	} catch (CLuceneError &err) {
@@ -357,6 +368,11 @@
 {
 	int ret = 0;
 
+	if (index->prev_uid == 0) {
+		/* no changes. */
+		return 0;
+	}
+
 	if (index->prev_uid > index->last_uid)
 		index->last_uid = index->prev_uid;
 	index->prev_uid = 0;
@@ -449,7 +465,6 @@
 	}
 
 	_CLDELETE(content_query);
-	lucene_index_close(index);
 	return ret;
 }
 



More information about the dovecot-cvs mailing list