From 55acda898cc001cc2db00bab336719364e0798f5 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Fri, 02 Mar 2012 18:58:20 -0500
Subject: [PATCH] Whoops. x2. LucenePage.html

---
 src/com/gitblit/LuceneExecutor.java |   41 ++++++++++++++++++++++++++++-------------
 1 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/src/com/gitblit/LuceneExecutor.java b/src/com/gitblit/LuceneExecutor.java
index 32004a7..b4e5134 100644
--- a/src/com/gitblit/LuceneExecutor.java
+++ b/src/com/gitblit/LuceneExecutor.java
@@ -29,6 +29,7 @@
 import com.gitblit.models.RepositoryModel;
 import com.gitblit.utils.JGitUtils;
 import com.gitblit.utils.LuceneUtils;
+import com.gitblit.utils.LuceneUtils.IndexResult;
 
 /**
  * The Lucene executor handles indexing repositories synchronously and
@@ -53,8 +54,8 @@
 
 	public LuceneExecutor(IStoredSettings settings) {
 		this.settings = settings;
-		this.isLuceneEnabled = settings.getBoolean("lucene.enableLucene", false);
-		this.isPollingMode = settings.getBoolean("lucene.pollingMode", false);		
+		this.isLuceneEnabled = settings.getBoolean(Keys.lucene.enable, false);
+		this.isPollingMode = settings.getBoolean(Keys.lucene.pollingMode, false);
 	}
 
 	/**
@@ -94,9 +95,9 @@
 		if (!isLuceneEnabled) {
 			return;
 		}
-		
+
 		if (firstRun.get() || isPollingMode) {
-			// update all indexes on first run or if polling mode 
+			// update all indexes on first run or if polling mode
 			firstRun.set(false);
 			queue.addAll(GitBlit.self().getRepositoryList());
 		}
@@ -117,7 +118,7 @@
 								"Lucene executor could not find repository {0}. Skipping.",
 								repositoryName));
 						continue;
-					}					
+					}
 					index(repositoryName, repository);
 					repository.close();
 					processed.add(repositoryName);
@@ -144,11 +145,14 @@
 				if (LuceneUtils.shouldReindex(repository)) {
 					// (re)build the entire index
 					long start = System.currentTimeMillis();
-					boolean success = LuceneUtils.reindex(repository);
+					IndexResult result = LuceneUtils.reindex(repository);
 					long duration = System.currentTimeMillis() - start;
-					if (success) {
-						String msg = "Built {0} Lucene index in {1} msecs";
-						logger.info(MessageFormat.format(msg, repositoryName, duration));
+					if (result.success) {
+						if (result.commitCount > 0) {
+							String msg = "Built {0} Lucene index from {1} commits in {2} msecs";
+							logger.info(MessageFormat.format(msg, repositoryName,
+									result.commitCount, duration));
+						}
 					} else {
 						String msg = "Could not build {0} Lucene index!";
 						logger.error(MessageFormat.format(msg, repositoryName));
@@ -156,11 +160,14 @@
 				} else {
 					// update the index with latest commits
 					long start = System.currentTimeMillis();
-					boolean success = LuceneUtils.updateIndex(repository);
+					IndexResult result = LuceneUtils.updateIndex(repository);
 					long duration = System.currentTimeMillis() - start;
-					if (success) {
-						String msg = "Updated {0} Lucene index in {1} msecs";
-						logger.info(MessageFormat.format(msg, repositoryName, duration));
+					if (result.success) {
+						if (result.commitCount > 0) {
+							String msg = "Updated {0} Lucene index with {1} commits in {2} msecs";
+							logger.info(MessageFormat.format(msg, repositoryName,
+									result.commitCount, duration));
+						}
 					} else {
 						String msg = "Could not update {0} Lucene index!";
 						logger.error(MessageFormat.format(msg, repositoryName));
@@ -174,4 +181,12 @@
 			logger.error(MessageFormat.format("Lucene indexing failure for {0}", repositoryName), t);
 		}
 	}
+
+	/**
+	 * Close all Lucene indexers.
+	 * 
+	 */
+	public void close() {
+		LuceneUtils.close();
+	}
 }

--
Gitblit v1.9.1