本文整理汇总了PHP中Zend_Search_Lucene_Storage_Directory::deleteFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Search_Lucene_Storage_Directory::deleteFile方法的具体用法?PHP Zend_Search_Lucene_Storage_Directory::deleteFile怎么用?PHP Zend_Search_Lucene_Storage_Directory::deleteFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Search_Lucene_Storage_Directory
的用法示例。
在下文中一共展示了Zend_Search_Lucene_Storage_Directory::deleteFile方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _generateCFS
/**
* Generate compound index file
*/
protected function _generateCFS()
{
$cfsFile = $this->_directory->createFile($this->_name . '.cfs');
$cfsFile->writeVInt(count($this->_files));
$dataOffsetPointers = array();
foreach ($this->_files as $fileName) {
$dataOffsetPointers[$fileName] = $cfsFile->tell();
$cfsFile->writeLong(0);
// write dummy data
$cfsFile->writeString($fileName);
}
foreach ($this->_files as $fileName) {
// Get actual data offset
$dataOffset = $cfsFile->tell();
// Seek to the data offset pointer
$cfsFile->seek($dataOffsetPointers[$fileName]);
// Write actual data offset value
$cfsFile->writeLong($dataOffset);
// Seek back to the end of file
$cfsFile->seek($dataOffset);
$dataFile = $this->_directory->getFileObject($fileName);
$byteCount = $this->_directory->fileLength($fileName);
while ($byteCount > 0) {
$data = $dataFile->readBytes(min($byteCount, 131072));
$byteCount -= strlen($data);
$cfsFile->writeBytes($data);
}
$this->_directory->deleteFile($fileName);
}
}
示例2: createIndex
public static function createIndex(Zend_Search_Lucene_Storage_Directory $directory, $generation, $nameCount)
{
if ($generation == 0) {
// Create index in pre-2.1 mode
foreach ($directory->fileList() as $file) {
if ($file == 'deletable' || $file == 'segments' || isset(self::$_indexExtensions[substr($file, strlen($file) - 4)]) || preg_match('/\\.f\\d+$/i', $file)) {
$directory->deleteFile($file);
}
}
$segmentsFile = $directory->createFile('segments');
$segmentsFile->writeInt((int) 0xffffffff);
// write version (is initialized by current time
// $segmentsFile->writeLong((int)microtime(true));
$version = microtime(true);
$segmentsFile->writeInt((int) ($version / ((double) 0xffffffff + 1)));
$segmentsFile->writeInt((int) ($version & 0xffffffff));
// write name counter
$segmentsFile->writeInt($nameCount);
// write segment counter
$segmentsFile->writeInt(0);
$deletableFile = $directory->createFile('deletable');
// write counter
$deletableFile->writeInt(0);
} else {
$genFile = $directory->createFile('segments.gen');
$genFile->writeInt((int) 0xfffffffe);
// Write generation two times
$genFile->writeLong($generation);
$genFile->writeLong($generation);
$segmentsFile = $directory->createFile(Zend_Search_Lucene::getSegmentFileName($generation));
$segmentsFile->writeInt((int) 0xfffffffd);
// write version (is initialized by current time
// $segmentsFile->writeLong((int)microtime(true));
$version = microtime(true);
$segmentsFile->writeInt((int) ($version / ((double) 0xffffffff + 1)));
$segmentsFile->writeInt((int) ($version & 0xffffffff));
// write name counter
$segmentsFile->writeInt($nameCount);
// write segment counter
$segmentsFile->writeInt(0);
}
}
示例3: __construct
/**
* Opens the index for writing
*
* IndexWriter constructor needs Directory as a parameter. It should be
* a string with a path to the index folder or a Directory object.
* Second constructor parameter create is optional - true to create the
* index or overwrite the existing one.
*
* @param Zend_Search_Lucene_Storage_Directory $directory
* @param boolean $create
*/
public function __construct(Zend_Search_Lucene_Storage_Directory $directory, $create = false)
{
$this->_directory = $directory;
if ($create) {
foreach ($this->_directory->fileList() as $file) {
if ($file == 'deletable' || $file == 'segments' || isset(self::$_indexExtensions[substr($file, strlen($file) - 4)]) || preg_match('/\\.f\\d+$/i', $file)) {
$this->_directory->deleteFile($file);
}
}
$segmentsFile = $this->_directory->createFile('segments');
$segmentsFile->writeInt((int) 0xffffffff);
// write version
$segmentsFile->writeLong(0);
// write name counter
$segmentsFile->writeInt(0);
// write segment counter
$segmentsFile->writeInt(0);
$deletableFile = $this->_directory->createFile('deletable');
// write counter
$deletableFile->writeInt(0);
$this->_version = 0;
$this->_segmentNameCounter = 0;
$this->_segments = 0;
} else {
$segmentsFile = $this->_directory->getFileObject('segments');
$format = $segmentsFile->readInt();
if ($format != (int) 0xffffffff) {
throw new Zend_Search_Lucene_Exception('Wrong segments file format');
}
// read version
$this->_version = $segmentsFile->readLong();
// read counter
$this->_segmentNameCounter = $segmentsFile->readInt();
// read segment counter
$this->_segments = $segmentsFile->readInt();
}
$this->_newSegments = array();
$this->_currentSegment = null;
}
示例4: _updateSegments
//.........这里部分代码省略.........
// second group of files for deletions
$filesNumbers[] = (int) base_convert($matches[2], 36, 10);
// order by segment number
}
} else {
if (preg_match('/(^_([a-zA-Z0-9]+))(_([a-zA-Z0-9]+))\\.del$/i', $file, $matches)) {
// one of per segment files ('<segment_name>_<del_generation>.del' where <segment_name> is '_<segment_number>')
// Check if it's not one of the segments in the current segments set
if (!isset($segments[$matches[1]])) {
$filesToDelete[] = $file;
$filesTypes[] = 3;
// second group of files for deletions
$filesNumbers[] = (int) base_convert($matches[2], 36, 10);
// order by segment number
} else {
$segmentNumber = (int) base_convert($matches[2], 36, 10);
$delGeneration = (int) base_convert($matches[4], 36, 10);
if (!isset($delFiles[$segmentNumber])) {
$delFiles[$segmentNumber] = array();
}
$delFiles[$segmentNumber][$delGeneration] = $file;
}
} else {
if (isset(self::$_indexExtensions[substr($file, strlen($file) - 4)])) {
// one of per segment files ('<segment_name>.<ext>')
$segmentName = substr($file, 0, strlen($file) - 4);
// Check if it's not one of the segments in the current segments set
if (!isset($segments[$segmentName]) && ($this->_currentSegment === null || $this->_currentSegment->getName() != $segmentName)) {
$filesToDelete[] = $file;
$filesTypes[] = 3;
// second group of files for deletions
$filesNumbers[] = (int) base_convert(substr($file, 1, strlen($file) - 5), 36, 10);
// order by segment number
}
}
}
}
}
}
}
}
$maxGenNumber = 0;
// process .del files of currently used segments
foreach ($delFiles as $segmentNumber => $segmentDelFiles) {
ksort($delFiles[$segmentNumber], SORT_NUMERIC);
array_pop($delFiles[$segmentNumber]);
// remove last delete file generation from candidates for deleting
end($delFiles[$segmentNumber]);
$lastGenNumber = key($delFiles[$segmentNumber]);
if ($lastGenNumber > $maxGenNumber) {
$maxGenNumber = $lastGenNumber;
}
}
foreach ($delFiles as $segmentNumber => $segmentDelFiles) {
foreach ($segmentDelFiles as $delGeneration => $file) {
$filesToDelete[] = $file;
$filesTypes[] = 4;
// third group of files for deletions
$filesNumbers[] = $segmentNumber * $maxGenNumber + $delGeneration;
// order by <segment_number>,<del_generation> pair
}
}
// Reorder files for deleting
array_multisort($filesTypes, SORT_ASC, SORT_NUMERIC, $filesNumbers, SORT_ASC, SORT_NUMERIC, $filesToDelete, SORT_ASC, SORT_STRING);
foreach ($filesToDelete as $file) {
try {
/** Skip shared docstore segments deleting */
/** @todo Process '.cfx' files to check if them are already unused */
if (substr($file, strlen($file) - 4) != '.cfx') {
$this->_directory->deleteFile($file);
}
} catch (Zend_Search_Lucene_Exception $e) {
if (strpos($e->getMessage(), 'Can\'t delete file') === false) {
// That's not "file is under processing or already deleted" exception
// Pass it through
throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e);
}
}
}
// Return read lock into the previous state
Zend_Search_Lucene_LockManager::deEscalateReadLock($this->_directory);
} else {
// Only release resources if another index reader is running now
foreach ($this->_segmentsToDelete as $segName) {
foreach (self::$_indexExtensions as $ext) {
$this->_directory->purgeFile($segName . $ext);
}
}
}
// Clean-up _segmentsToDelete container
$this->_segmentsToDelete = array();
// Release index write lock
Zend_Search_Lucene_LockManager::releaseWriteLock($this->_directory);
// Remove unused segments from segments list
foreach ($this->_segmentInfos as $segName => $segmentInfo) {
if (!isset($segments[$segName])) {
unset($this->_segmentInfos[$segName]);
}
}
}
示例5: _updateSegments
//.........这里部分代码省略.........
$filesNumbers[] = (int)base_convert(substr($file, 9), 36, 10); // ordered by segment generation numbers
}
} else if (preg_match('/(^_([a-zA-Z0-9]+))\.f\d+$/i', $file, $matches)) {
// one of per segment files ('<segment_name>.f<decimal_number>')
// Check if it's not one of the segments in the current segments set
if (!isset($segments[$matches[1]])) {
$filesToDelete[] = $file;
$filesTypes[] = 3; // second group of files for deletions
$filesNumbers[] = (int)base_convert($matches[2], 36, 10); // order by segment number
}
} else if (preg_match('/(^_([a-zA-Z0-9]+))(_([a-zA-Z0-9]+))\.del$/i', $file, $matches)) {
// one of per segment files ('<segment_name>_<del_generation>.del' where <segment_name> is '_<segment_number>')
// Check if it's not one of the segments in the current segments set
if (!isset($segments[$matches[1]])) {
$filesToDelete[] = $file;
$filesTypes[] = 3; // second group of files for deletions
$filesNumbers[] = (int)base_convert($matches[2], 36, 10); // order by segment number
} else {
$segmentNumber = (int)base_convert($matches[2], 36, 10);
$delGeneration = (int)base_convert($matches[4], 36, 10);
if (!isset($delFiles[$segmentNumber])) {
$delFiles[$segmentNumber] = array();
}
$delFiles[$segmentNumber][$delGeneration] = $file;
}
} else if (isset(self::$_indexExtensions[substr($file, strlen($file)-4)])) {
// one of per segment files ('<segment_name>.<ext>')
$segmentName = substr($file, 0, strlen($file) - 4);
// Check if it's not one of the segments in the current segments set
if (!isset($segments[$segmentName]) &&
($this->_currentSegment === null || $this->_currentSegment->getName() != $segmentName)) {
$filesToDelete[] = $file;
$filesTypes[] = 3; // second group of files for deletions
$filesNumbers[] = (int)base_convert(substr($file, 1 /* skip '_' */, strlen($file)-5), 36, 10); // order by segment number
}
}
}
$maxGenNumber = 0;
// process .del files of currently used segments
foreach ($delFiles as $segmentNumber => $segmentDelFiles) {
ksort($delFiles[$segmentNumber], SORT_NUMERIC);
array_pop($delFiles[$segmentNumber]); // remove last delete file generation from candidates for deleting
end($delFiles[$segmentNumber]);
$lastGenNumber = key($delFiles[$segmentNumber]);
if ($lastGenNumber > $maxGenNumber) {
$maxGenNumber = $lastGenNumber;
}
}
foreach ($delFiles as $segmentNumber => $segmentDelFiles) {
foreach ($segmentDelFiles as $delGeneration => $file) {
$filesToDelete[] = $file;
$filesTypes[] = 4; // third group of files for deletions
$filesNumbers[] = $segmentNumber*$maxGenNumber + $delGeneration; // order by <segment_number>,<del_generation> pair
}
}
// Reorder files for deleting
array_multisort($filesTypes, SORT_ASC, SORT_NUMERIC,
$filesNumbers, SORT_ASC, SORT_NUMERIC,
$filesToDelete, SORT_ASC, SORT_STRING);
foreach ($filesToDelete as $file) {
try {
$this->_directory->deleteFile($file);
} catch (Zend_Search_Lucene_Exception $e) {
if (strpos($e->getMessage(), 'Can\'t delete file') === false) {
// That's not "file is under processing or already deleted" exception
// Pass it through
throw $e;
}
}
}
// Return read lock into the previous state
Zend_Search_Lucene_LockManager::deEscalateReadLock($this->_directory);
} else {
// Only release resources if another index reader is running now
foreach ($this->_segmentsToDelete as $segName) {
foreach (self::$_indexExtensions as $ext) {
$this->_directory->purgeFile($segName . $ext);
}
}
}
// Clean-up _segmentsToDelete container
$this->_segmentsToDelete = array();
// Release index write lock
Zend_Search_Lucene_LockManager::releaseWriteLock($this->_directory);
// Remove unused segments from segments list
foreach ($this->_segmentInfos as $segName => $segmentInfo) {
if (!isset($segments[$segName])) {
unset($this->_segmentInfos[$segName]);
}
}
}
示例6: _updateSegments
/**
* Update segments file by adding current segment to a list
*
* @throws Zend_Search_Lucene_Exception
*/
private function _updateSegments()
{
// Get an exclusive index lock
// Wait, until all parallel searchers or indexers won't stop
// and stop all next searchers, while we are updating segments file
$lock = $this->_directory->getFileObject('index.lock');
if (!$lock->lock(LOCK_EX)) {
throw new Zend_Search_Lucene_Exception('Can\'t obtain exclusive index lock');
}
// Do not share file handlers to get file updates from other sessions.
$segmentsFile = $this->_directory->getFileObject('segments', false);
$newSegmentFile = $this->_directory->createFile('segments.new', false);
// Write format marker
$newSegmentFile->writeInt((int) 0xffffffff);
// Write index version
$segmentsFile->seek(4, SEEK_CUR);
$version = $segmentsFile->readLong() + $this->_versionUpdate;
$this->_versionUpdate = 0;
$newSegmentFile->writeLong($version);
// Write segment name counter
$newSegmentFile->writeInt($segmentsFile->readInt());
// Get number of segments offset
$numOfSegmentsOffset = $newSegmentFile->tell();
// Write number of segemnts
$segmentsCount = $segmentsFile->readInt();
$newSegmentFile->writeInt(0);
// Write dummy data (segment counter)
$segments = array();
for ($count = 0; $count < $segmentsCount; $count++) {
$segName = $segmentsFile->readString();
$segSize = $segmentsFile->readInt();
if (!in_array($segName, $this->_segmentsToDelete)) {
$newSegmentFile->writeString($segName);
$newSegmentFile->writeInt($segSize);
$segments[$segName] = $segSize;
}
}
$segmentsFile->close();
$segmentsCount = count($segments) + count($this->_newSegments);
// Remove segments, not listed in $segments (deleted)
// Load segments, not listed in $this->_segmentInfos
foreach ($this->_segmentInfos as $segId => $segInfo) {
if (isset($segments[$segInfo->getName()])) {
// Segment is already included into $this->_segmentInfos
unset($segments[$segInfo->getName()]);
} else {
// remove deleted segment from a list
unset($this->_segmentInfos[$segId]);
}
}
// $segments contains a list of segments to load
// do it later
foreach ($this->_newSegments as $segName => $segmentInfo) {
$newSegmentFile->writeString($segName);
$newSegmentFile->writeInt($segmentInfo->count());
$this->_segmentInfos[] = $segmentInfo;
}
$this->_newSegments = array();
$newSegmentFile->seek($numOfSegmentsOffset);
$newSegmentFile->writeInt($segmentsCount);
// Update segments count
$newSegmentFile->close();
$this->_directory->renameFile('segments.new', 'segments');
// Segments file update is finished
// Switch back to shared lock mode
$lock->lock(LOCK_SH);
$fileList = $this->_directory->fileList();
foreach ($this->_segmentsToDelete as $nameToDelete) {
foreach (self::$_indexExtensions as $ext) {
if ($this->_directory->fileExists($nameToDelete . $ext)) {
$this->_directory->deleteFile($nameToDelete . $ext);
}
}
foreach ($fileList as $file) {
if (substr($file, 0, strlen($nameToDelete) + 2) == $nameToDelete . '.f' && ctype_digit(substr($file, strlen($nameToDelete) + 2))) {
$this->_directory->deleteFile($file);
}
}
}
$this->_segmentsToDelete = array();
// Load segments, created by other process
foreach ($segments as $segName => $segSize) {
// Load new segments
$this->_segmentInfos[] = new Zend_Search_Lucene_Index_SegmentInfo($segName, $segSize, $this->_directory);
}
}
示例7: _updateSegments
/**
* Update segments file by adding current segment to a list
*
* @todo !!!! locks should be processed to prevent concurrent access errors
*
* @throws Zend_Search_Lucene_Exception
*/
private function _updateSegments()
{
$segmentsFile = $this->_directory->getFileObject('segments');
$newSegmentFile = $this->_directory->createFile('segments.new');
// Write format marker
$newSegmentFile->writeInt((int) 0xffffffff);
// Write index version
$segmentsFile->seek(4, SEEK_CUR);
$version = $segmentsFile->readLong() + $this->_versionUpdate;
$this->_versionUpdate = 0;
$newSegmentFile->writeLong($version);
// Write segment name counter
$newSegmentFile->writeInt($segmentsFile->readInt());
// Write number of segemnts
$segments = $segmentsFile->readInt();
$newSegmentFile->writeInt($segments + count($this->_newSegments) - count($this->_segmentsToDelete));
for ($count = 0; $count < $segments; $count++) {
$segName = $segmentsFile->readString();
$segSize = $segmentsFile->readInt();
if (!array_key_exists($segName, $this->_segmentsToDelete)) {
$newSegmentFile->writeString($segName);
$newSegmentFile->writeInt($segSize);
}
}
foreach ($this->_newSegments as $segmentName => $segmentInfo) {
$newSegmentFile->writeString($segmentName);
$newSegmentFile->writeInt($segmentInfo->count());
$this->_segmentInfos[] = $segmentInfo;
}
$this->_newSegments = array();
$fileList = $this->_directory->fileList();
foreach ($this->_segmentsToDelete as $nameToDelete) {
foreach ($this->_segmentInfos as $segId => $segInfo) {
if ($segInfo->getName() == $nameToDelete) {
unset($this->_segmentInfos[$segId]);
}
}
foreach (self::$_indexExtensions as $ext) {
if ($this->_directory->fileExists($nameToDelete . $ext)) {
$this->_directory->deleteFile($nameToDelete . $ext);
}
}
foreach ($fileList as $file) {
if (substr($file, 0, strlen($nameToDelete) + 2) == $nameToDelete . '.f' && ctype_digit(substr($file, strlen($nameToDelete) + 2))) {
$this->_directory->deleteFile($file);
}
}
}
$this->_segmentsToDelete = array();
$this->_directory->renameFile('segments.new', 'segments');
}
示例8: releaseWriteLock
/**
* Free exclusive write lock on the index
*
* @param Zend_Search_Lucene_Storage_Directory $defaultLockDirectory
* @param Zend_Search_Lucene_Storage_File $lock
*/
public static function releaseWriteLock(Zend_Search_Lucene_Storage_Directory $defaultLockDirectory, Zend_Search_Lucene_Storage_File $lock)
{
$lock->unlock();
unset($lock);
$defaultLockDirectory->deleteFile('write.lock');
}
示例9: releaseOptimizationLock
/**
* Release exclusive optimization lock
*
* @param Zend_Search_Lucene_Storage_Directory $lockDirectory
*/
public static function releaseOptimizationLock(Zend_Search_Lucene_Storage_Directory $lockDirectory)
{
$lockDirectory->deleteFile(self::OPTIMIZATION_LOCK_FILE);
}
示例10: createIndex
public static function createIndex(Zend_Search_Lucene_Storage_Directory $directory, $generation, $nameCount)
{
if ($generation == 0) {
foreach ($directory->fileList() as $file) {
if ($file == 'deletable' || $file == 'segments' || isset(self::$_indexExtensions[substr($file, strlen($file) - 4)]) || preg_match('/\\.f\\d+$/i', $file)) {
$directory->deleteFile($file);
}
}
$segmentsFile = $directory->createFile('segments');
$segmentsFile->writeInt((int) 0xffffffff);
$segmentsFile->writeLong(round(microtime(true)));
$segmentsFile->writeInt($nameCount);
$segmentsFile->writeInt(0);
$deletableFile = $directory->createFile('deletable');
$deletableFile->writeInt(0);
} else {
$genFile = $directory->createFile('segments.gen');
$genFile->writeInt((int) 0xfffffffe);
$genFile->writeLong($generation);
$genFile->writeLong($generation);
$segmentsFile = $directory->createFile(Zend_Search_Lucene::getSegmentFileName($generation));
$segmentsFile->writeInt((int) 0xfffffffd);
$segmentsFile->writeLong(round(microtime(true)));
$segmentsFile->writeInt($nameCount);
$segmentsFile->writeInt(0);
}
}
示例11: _updateSegments
//.........这里部分代码省略.........
$normGens[] = $segmentsFile->readLong();
}
}
$isCompound = $segmentsFile->readByte();
}
if (!in_array($segName, $this->_segmentsToDelete)) {
// Load segment if necessary
if (!isset($this->_segmentInfos[$segName])) {
$delGen = $delGenHigh * ((double) 0xffffffff + 1) + ($delGenLow < 0 ? (double) 0xffffffff - (-1 - $delGenLow) : $delGenLow);
$this->_segmentInfos[$segName] = new Zend_Search_Lucene_Index_SegmentInfo($this->_directory, $segName, $segSize, $delGen, $hasSingleNormFile, $isCompound);
} else {
// Retrieve actual detetions file generation number
$delGen = $this->_segmentInfos[$segName]->getDelGen();
if ($delGen >= 0) {
$delGenHigh = (int) ($delGen / ((double) 0xffffffff + 1));
$delGenLow = (int) ($delGen & 0xffffffff);
} else {
$delGenHigh = $delGenLow = (int) 0xffffffff;
}
}
$newSegmentFile->writeString($segName);
$newSegmentFile->writeInt($segSize);
$newSegmentFile->writeInt($delGenHigh);
$newSegmentFile->writeInt($delGenLow);
$newSegmentFile->writeByte($hasSingleNormFile);
$newSegmentFile->writeInt($numField);
if ($numField != (int) 0xffffffff) {
foreach ($normGens as $normGen) {
$newSegmentFile->writeLong($normGen);
}
}
$newSegmentFile->writeByte($isCompound);
$segments[$segName] = $segSize;
}
}
$segmentsFile->close();
$segmentsCount = count($segments) + count($this->_newSegments);
foreach ($this->_newSegments as $segName => $segmentInfo) {
$newSegmentFile->writeString($segName);
$newSegmentFile->writeInt($segmentInfo->count());
// delete file generation: -1 (there is no delete file yet)
$newSegmentFile->writeInt((int) 0xffffffff);
$newSegmentFile->writeInt((int) 0xffffffff);
// HasSingleNormFile
$newSegmentFile->writeByte($segmentInfo->hasSingleNormFile());
// NumField
$newSegmentFile->writeInt((int) 0xffffffff);
// IsCompoundFile
$newSegmentFile->writeByte($segmentInfo->isCompound());
$segments[$segmentInfo->getName()] = $segmentInfo->count();
$this->_segmentInfos[$segName] = $segmentInfo;
}
$this->_newSegments = array();
$newSegmentFile->seek($numOfSegmentsOffset);
$newSegmentFile->writeInt($segmentsCount);
// Update segments count
$newSegmentFile->close();
// Clean-up directory
foreach ($this->_directory->fileList() as $file) {
if ($file == 'deletable' || $file == 'segments' || isset(self::$_indexExtensions[substr($file, strlen($file) - 4)]) || preg_match('/^segments_[a-zA-Z0-9]+$/i', $file) || preg_match('/\\.f\\d+$/i', $file)) {
// check, that file is not used by current index generation
if ($file == Zend_Search_Lucene::getSegmentFileName($generation) || isset($segments[substr($file, 0, strlen($file) - 4)]) || isset($segments[substr($file, 0, strpos($file, '.f'))]) || substr($file, strlen($file) - 4) == '.del') {
continue;
}
try {
$this->_directory->deleteFile($file);
} catch (Zend_Search_Lucene_Exception $e) {
if (strpos($e->getMessage(), 'Can\'t delete file') === 0) {
// File is under processing
// Stop clean-up process
break;
} else {
throw $e;
}
}
}
}
} catch (Exception $e) {
/** Restore previous index generation */
$generation--;
$genFile->seek(4, SEEK_SET);
// Write generation number twice
$genFile->writeLong($generation);
$genFile->writeLong($generation);
// Release index write lock
Zend_Search_Lucene::releaseWriteLock($this->_directory, $lock);
// Throw the exception
throw $e;
}
// Write generation (second copy)
$genFile->writeLong($generation);
// Release index write lock
Zend_Search_Lucene::releaseWriteLock($this->_directory, $lock);
// Remove unused segments from segments list
foreach ($this->_segmentInfos as $segName => $segmentInfo) {
if (!isset($segments[$segName])) {
unset($this->_segmentInfos[$segName]);
}
}
}