Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dokuwiki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BRIC
dokuwiki
Commits
3cf3c7d6
Commit
3cf3c7d6
authored
12 years ago
by
Michael Hamann
Browse files
Options
Downloads
Patches
Plain Diff
Add clear function to the indexer that deletes the whole index
parent
1421e548
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bin/indexer.php
+1
-51
1 addition, 51 deletions
bin/indexer.php
inc/indexer.php
+32
-0
32 additions, 0 deletions
inc/indexer.php
with
33 additions
and
51 deletions
bin/indexer.php
+
1
−
51
View file @
3cf3c7d6
...
...
@@ -91,63 +91,13 @@ function _index($id){
_quietecho
(
"done.
\n
"
);
}
/**
* 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
)
{
...
...
This diff is collapsed.
Click to expand it.
inc/indexer.php
+
32
−
0
View file @
3cf3c7d6
...
...
@@ -401,6 +401,38 @@ class Doku_Indexer {
return
true
;
}
/**
* Clear the whole index
*
* @return bool If the index has been cleared successfully
*/
public
function
clear
()
{
global
$conf
;
if
(
!
$this
->
lock
())
return
false
;
@
unlink
(
$conf
[
'indexdir'
]
.
'/page.idx'
);
@
unlink
(
$conf
[
'indexdir'
]
.
'/title.idx'
);
@
unlink
(
$conf
[
'indexdir'
]
.
'/pageword.idx'
);
@
unlink
(
$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'
);
// clear the pid cache
$this
->
pidCache
=
array
();
$this
->
unlock
();
return
true
;
}
/**
* Split the text into words for fulltext search
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment