};
}
-sub search ($;$) {
- my ($self, $over_only) = @_;
+sub search ($;$$) {
+ my ($self, $over_only, $ctx) = @_;
my $srch = $self->{search} ||= eval {
_cleanup_later($self);
require PublicInbox::Search;
PublicInbox::Search->new($self);
};
- ($over_only || eval { $srch->xdb }) ? $srch : undef;
+ ($over_only || eval { $srch->xdb }) ? $srch : do {
+ $ctx and $ctx->{env}->{'psgi.errors'}->print(<<EOF);
+`$self->{name}' search went away unexpectedly
+EOF
+ undef;
+ };
}
sub over ($) {
sub results_cb {
my ($ctx) = @_;
+ my $srch = $ctx->{-inbox}->search(undef, $ctx) or return;
my $mset = $ctx->{mset};
- my $srch = $ctx->{srch};
while (1) {
while (my $mi = (($mset->items)[$ctx->{iter}++])) {
my $smsg = PublicInbox::Smsg::from_mitem($mi,
return mbox_all_ids($ctx) if $query eq '';
my $qopts = $ctx->{qopts} = { mset => 2 };
- my $srch = $ctx->{srch} = $ctx->{-inbox}->search or
- return PublicInbox::WWW::need($ctx, 'Search');;
+ my $srch = $ctx->{-inbox}->search or
+ return PublicInbox::WWW::need($ctx, 'Search');
my $mset = $ctx->{mset} = $srch->query($query, $qopts);
$qopts->{offset} = $mset->size or
return [404, [qw(Content-Type text/plain)],
my ($cb, $mset, $q, $ctx) = @_;
$ctx->{items} = [ $mset->items ];
$ctx->{search_query} = $q; # used by WwwAtomStream::atom_header
- $ctx->{srch} = $ctx->{-inbox}->search;
PublicInbox::WwwAtomStream->response($ctx, 200, \&adump_i);
}
sub adump_i {
my ($ctx) = @_;
while (my $mi = shift @{$ctx->{items}}) {
+ my $srch = $ctx->{-inbox}->search(undef, $ctx) or return;
my $smsg = eval {
- PublicInbox::Smsg::from_mitem($mi, $ctx->{srch});
+ PublicInbox::Smsg::from_mitem($mi, $srch);
} or next;
return $smsg;
}