SOLR-687: only unlockOnStartup the first time for each dir

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@684333 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2008-08-09 20:27:24 +00:00
parent 2ff01c14b9
commit 0084c7e57c
1 changed files with 6 additions and 2 deletions

View File

@ -259,13 +259,17 @@ public final class SolrCore {
}
// protect via synchronized(SolrCore.class)
private static Set<String> dirs = new HashSet<String>();
// currently only called with SolrCore.class lock held
void initIndex() {
try {
File dirFile = new File(getIndexDir());
boolean indexExists = dirFile.canRead();
boolean firstTime = dirs.add(dirFile.getCanonicalPath());
boolean removeLocks = solrConfig.getBool("mainIndex/unlockOnStartup", false);
if (indexExists && removeLocks) {
if (indexExists && firstTime && removeLocks) {
// to remove locks, the directory must already exist... so we create it
// if it didn't exist already...
Directory dir = SolrIndexWriter.getDirectory(getIndexDir(), solrConfig.mainIndexConfig);