summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTom N Harris <tnharris@whoopdedo.org>2007-02-02 07:35:11 +0100
committerTom N Harris <tnharris@whoopdedo.org>2007-02-02 07:35:11 +0100
commit66b955446096380d27c59fb00f6d4208b42eb800 (patch)
tree1cf7b5e33f126a36a28fc6a8e8186e4b4996fb08 /bin
parent37daf7b06c75c38fc76ee792fddc7e75242e0ed4 (diff)
downloadrpg-66b955446096380d27c59fb00f6d4208b42eb800.tar.gz
rpg-66b955446096380d27c59fb00f6d4208b42eb800.tar.bz2
Use new index format in bin/indexer.php
darcs-hash:20070202063511-6942e-227499f5baaedea2d8df72d156bcdb8d6d5461bc.gz
Diffstat (limited to 'bin')
-rwxr-xr-xbin/indexer.php27
1 files changed, 21 insertions, 6 deletions
diff --git a/bin/indexer.php b/bin/indexer.php
index 769cecffe..7b4e7d197 100755
--- a/bin/indexer.php
+++ b/bin/indexer.php
@@ -11,6 +11,10 @@ require_once(DOKU_INC.'inc/indexer.php');
require_once(DOKU_INC.'inc/cliopts.php');
session_write_close();
+// Version tag used to force rebuild on upgrade
+// Need to keep in sync with lib/exe/indexer.php
+if(!defined('INDEXER_VERSION')) define('INDEXER_VERSION', 1);
+
// handle options
$short_opts = 'hcu';
$long_opts = array('help', 'clean', 'update');
@@ -73,14 +77,19 @@ function _index($id){
// if not cleared only update changed and new files
if(!$CLEAR){
- $last = @filemtime(metaFN($id,'.indexed'));
- if($last > @filemtime(wikiFN($id))) return;
+ $idxtag = metaFN($id,'.indexed');
+ if(@file_exists($idxtag)){
+ if(io_readFile($idxtag) >= INDEXER_VERSION){
+ $last = @filemtime(metaFN($id,'.indexed'));
+ if($last > @filemtime(wikiFN($id))) return;
+ }
+ }
}
_lock();
echo "$id... ";
idx_addPage($id);
- io_saveFile(metaFN($id,'.indexed'),' ');
+ io_saveFile(metaFN($id,'.indexed'),INDEXER_VERSION);
echo "done.\n";
_unlock();
}
@@ -126,9 +135,15 @@ function _clearindex(){
global $conf;
_lock();
echo "Clearing index... ";
- io_saveFile($conf['cachedir'].'/word.idx','');
- io_saveFile($conf['cachedir'].'/page.idx','');
- io_saveFile($conf['cachedir'].'/index.idx','');
+ io_saveFile($conf['indexdir'].'/page.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'))
+ @unlink($conf['indexdir']."/$f");
+ }
+ }
echo "done.\n";
_unlock();
}