diff --git a/search2/indexing/indexerCore.inc.php b/search2/indexing/indexerCore.inc.php index 6f76776..00ee8f5 100755 --- a/search2/indexing/indexerCore.inc.php +++ b/search2/indexing/indexerCore.inc.php @@ -664,16 +664,27 @@ abstract class Indexer public function indexDocuments($max=null) { global $default; + $config =& KTConfig::getSingleton(); + + $indexLockFile = $config->get('cache/cacheDirectory') . '/main.index.lock'; + if (is_file($indexLockFile)) + { + $default->log->info('indexDocuments: main.index.lock seems to exist. it could be that the indexing is still underway.'); + $default->log->info('indexDocuments: Remove "' . $indexLockFile . '" if the indexing is not running or extend the frequency at which the background task runs!'); + return; + } + touch($indexLockFile); + $this->checkForRegisteredTypes(); $default->log->info('indexDocuments: start'); if (!$this->doesDiagnosticsPass()) { + unlink($indexLockFile); return; } - $config =& KTConfig::getSingleton(); if (is_null($max)) { $max = $config->get('indexer/batchDocuments',20); @@ -702,12 +713,14 @@ abstract class Indexer $result = DBUtil::getResultArray($sql); if (PEAR::isError($result)) { + unlink($indexLockFile); return; } // bail if no work to do if (count($result) == 0) { + unlink($indexLockFile); return; } @@ -915,6 +928,7 @@ abstract class Indexer } $default->log->info('indexDocuments: done'); + unlink($indexLockFile); } public function migrateDocuments($max=null)