Fix search indexing on Windows and make function savfer overall.

This commit is contained in:
Graham Knop 2007-05-02 16:31:49 +00:00
parent af136bb772
commit ff756eb09c
2 changed files with 16 additions and 8 deletions

View file

@ -48,14 +48,21 @@ The path to the filename to index, including the filename.
=cut
sub addFile {
my $self = shift;
my $path = shift;
$path =~ m/\.(\w+)$/;
my $type = lc($1);
my $filters = $self->session->config->get("searchIndexerPlugins");
my $filter = $filters->{$type};
my $content = `$filter $path`;
$self->addKeywords($content) if (!$content =~ m/^\s*$/);
my $self = shift;
my $path = shift;
my $filters = $self->session->config->get("searchIndexerPlugins");
my $content;
if ($path =~ m/\.(\w+)$/) {
my $type = lc($1);
if ($filters->{$type}) {
open my $fh, "$filters->{$type} $path |" or return; # open pipe to filter
$content = do { local $/; <$fh> }; # slurp file
close $fh;
}
}
return $self->addKeywords($content)
if $content =~ m/\S/; # only index if we fine non-whitespace
return;
}