--- lib/Grep/Search.pm 2007/02/21 17:42:24 57 +++ lib/Grep/Search.pm 2007/02/21 19:10:20 58 @@ -12,15 +12,21 @@ my ( $analyzer, $store, $writer ); my $debug = 1; +my $create; sub create { - my $create = 0; + if (defined( $create )) { + Jifty->log->debug("using previous create $create"); + return $create; + } + if (! -e "$index_path/segments") { $create = 1; - Jifty->log->debug("create index $index_path") unless ($store); + Jifty->log->debug("create index $index_path"); } else { - Jifty->log->debug("open index: $index_path") unless ($store); + $create = 0; + Jifty->log->debug("open index: $index_path"); } return $create; } @@ -120,6 +126,8 @@ my $q = shift or die "no q?"; + return if ( $self->create ); + my $searcher = new Lucene::Search::IndexSearcher($self->store); my $parser = new Lucene::QueryParser("content", $self->analyzer); my $query = $parser->parse( $q ); @@ -177,6 +185,9 @@ $writer->close; } undef $writer; + undef $create; + + return; } =for TODO