summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorMichael Hamann <michael@content-space.de>2012-12-20 17:47:05 +0100
committerMichael Hamann <michael@content-space.de>2012-12-20 17:47:05 +0100
commit3cf3c7d60c81d562c8331a377a76e86d41f8f528 (patch)
tree593a7b49956b59614e1dc5495bd472e7b6e7f187 /bin
parent1421e5483ad1ca8780331077141e0c07b6530bc5 (diff)
downloadrpg-3cf3c7d60c81d562c8331a377a76e86d41f8f528.tar.gz
rpg-3cf3c7d60c81d562c8331a377a76e86d41f8f528.tar.bz2
Add clear function to the indexer that deletes the whole index
Diffstat (limited to 'bin')
-rwxr-xr-xbin/indexer.php52
1 files changed, 1 insertions, 51 deletions
diff --git a/bin/indexer.php b/bin/indexer.php
index f6aeb4f0e..78f470ae0 100755
--- a/bin/indexer.php
+++ b/bin/indexer.php
@@ -92,62 +92,12 @@ function _index($id){
}
/**
- * lock the indexer system
- */
-function _lock(){
- global $conf;
- $lock = $conf['lockdir'].'/_indexer.lock';
- $said = false;
- while(!@mkdir($lock, $conf['dmode'])){
- if(time()-@filemtime($lock) > 60*5){
- // looks like a stale lock - remove it
- @rmdir($lock);
- }else{
- if($said){
- _quietecho(".");
- }else{
- _quietecho("Waiting for lockfile (max. 5 min)");
- $said = true;
- }
- sleep(15);
- }
- }
- if($conf['dperm']) chmod($lock, $conf['dperm']);
- if($said) _quietecho("\n");
-}
-
-/**
- * unlock the indexer sytem
- */
-function _unlock(){
- global $conf;
- $lock = $conf['lockdir'].'/_indexer.lock';
- @rmdir($lock);
-}
-
-/**
* Clear all index files
*/
function _clearindex(){
- global $conf;
- _lock();
_quietecho("Clearing index... ");
- io_saveFile($conf['indexdir'].'/page.idx','');
- io_saveFile($conf['indexdir'].'/title.idx','');
- io_saveFile($conf['indexdir'].'/pageword.idx','');
- io_saveFile($conf['indexdir'].'/metadata.idx','');
- $dir = @opendir($conf['indexdir']);
- if($dir!==false){
- while(($f = readdir($dir)) !== false){
- if(substr($f,-4)=='.idx' &&
- (substr($f,0,1)=='i' || substr($f,0,1)=='w'
- || substr($f,-6)=='_w.idx' || substr($f,-6)=='_i.idx' || substr($f,-6)=='_p.idx'))
- @unlink($conf['indexdir']."/$f");
- }
- }
- @unlink($conf['indexdir'].'/lengths.idx');
+ idx_get_indexer()->clear();
_quietecho("done.\n");
- _unlock();
}
function _quietecho($msg) {