about summary refs log tree commit homepage
path: root/lib/PublicInbox/Inbox.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-12-05 10:11:37 +0000
committerEric Wong <e@80x24.org>2020-12-05 21:41:52 +0000
commit89990b0cfc8bbdabc8d650325d9e1bc585df8a0c (patch)
treece962a5a8d00ed83c3f6caa5c1e5e91ec1966aaf /lib/PublicInbox/Inbox.pm
parent8e0aef5068aa71e58d4a049491229f41e6bf19fb (diff)
downloadpublic-inbox-89990b0cfc8bbdabc8d650325d9e1bc585df8a0c.tar.gz
inbox: simplify ->search and callers
Stop leaking WWW/PSGI-specific logic into classes like
PublicInbox::Inbox, which is used universally.

We'll also decouple $ibx->over from $ibx->search and just deal
with duplicate the code inside ->over to reduce argument
complexity in ->search.

This is also a step in moving away from using {psgi.errors}
to ease code sharing between IMAP, NNTP, and command-line
interfaces.  Perl's built-in `warn' and `local $SIG{__WARN__}'
provides all the flexibility we need to control warning output
and should be universally understood by Perl hackers who may
be unfamiliar with PSGI.
Diffstat (limited to 'lib/PublicInbox/Inbox.pm')
-rw-r--r--lib/PublicInbox/Inbox.pm20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index 5a22e40d..58651687 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -191,30 +191,30 @@ sub mm {
         };
 }
 
-sub search ($;$$) {
-        my ($self, $over_only, $ctx) = @_;
-        my $srch = $self->{search} ||= eval {
+sub search {
+        my ($self) = @_;
+        my $srch = $self->{search} //= eval {
                 _cleanup_later($self);
                 require PublicInbox::Search;
                 PublicInbox::Search->new($self);
         };
-        ($over_only || eval { $srch->xdb }) ? $srch : do {
-                $ctx and $ctx->{env}->{'psgi.errors'}->print(<<EOF);
-`$self->{name}' search went away unexpectedly
-EOF
-                undef;
-        };
+        (eval { $srch->xdb }) ? $srch : undef;
 }
 
 sub over {
         $_[0]->{over} //= eval {
-                my $srch = search($_[0], 1) or return;
+                my $srch = $_[0]->{search} //= eval {
+                        _cleanup_later($_[0]);
+                        require PublicInbox::Search;
+                        PublicInbox::Search->new($_[0]);
+                };
                 my $over = PublicInbox::Over->new("$srch->{xpfx}/over.sqlite3");
                 $over->dbh; # may fail
                 $over;
         };
 }
 
+
 sub try_cat {
         my ($path) = @_;
         my $rv = '';