Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Make sure to unset currentIndex to trigger the __destruct function an…
Browse files Browse the repository at this point in the history
…d release all handlers on files. Prevented the cleaning of the TMP index on Windows.
  • Loading branch information
cdujeu committed Feb 26, 2015
1 parent 73a1f43 commit 15b8d4d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion core/src/plugins/index.lucene/class.AjxpLuceneIndexer.php
Expand Up @@ -333,6 +333,7 @@ public function indexationEnds($parentNode){
$this->currentIndex->optimize();
$this->logDebug('INDEX.END', 'Commiting Index');
$this->currentIndex->commit();
unset($this->currentIndex);
$this->logDebug('INDEX.END', 'Merging Temporary in main');
$this->mergeTemporaryIndexToMain($parentNode->getRepositoryId());
$this->logDebug('INDEX.END', 'Done');
Expand Down Expand Up @@ -684,7 +685,7 @@ protected function mergeTemporaryIndexToMain($repositoryId){
$indexPath = $this->getIndexPath($repositoryId);
$tmpIndexPath = $indexPath."-PYDIO_TMP";
$this->clearIndexIfExists($indexPath);
$this->copyIndex($tmpIndexPath, $indexPath);
$this->moveIndex($tmpIndexPath, $indexPath);
$this->clearIndexIfExists($tmpIndexPath);
}

Expand Down Expand Up @@ -716,6 +717,21 @@ private function copyIndex($folder1, $folder2){
}


/**
* @param $folder1
* @param $folder2
*/
private function moveIndex($folder1, $folder2){
if(!is_dir($folder1))return;
if(!is_dir($folder2)) mkdir($folder2, 0755);
$content = scandir($folder1);
foreach($content as $file){
if($file == "." || $file == "..") continue;
rename($folder1.DIRECTORY_SEPARATOR.$file, $folder2.DIRECTORY_SEPARATOR.$file);
}
}


/**
*
* Enter description here ...
Expand Down

0 comments on commit 15b8d4d

Please sign in to comment.