about summary refs log tree commit homepage
path: root/lib/PublicInbox/Config.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-10-27 07:54:49 +0000
committerEric Wong <e@80x24.org>2020-11-07 10:22:09 +0000
commitd2eb1ae16e4d3aaa5bece96f17b2fa4561d5b18e (patch)
tree1fe34db78d6ded9412c3ea1c9d0792cadb198930 /lib/PublicInbox/Config.pm
parent9ebb1544ac677d3ed37231cfd78624916b6f2945 (diff)
downloadpublic-inbox-d2eb1ae16e4d3aaa5bece96f17b2fa4561d5b18e.tar.gz
This lets us pretend an ExtSearch object is an Inbox object
in most of the existing WWW code.
Diffstat (limited to 'lib/PublicInbox/Config.pm')
-rw-r--r--lib/PublicInbox/Config.pm12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm
index d57c361a..d425cc9b 100644
--- a/lib/PublicInbox/Config.pm
+++ b/lib/PublicInbox/Config.pm
@@ -89,6 +89,11 @@ sub lookup_name ($$) {
         $self->{-by_name}->{$name} // _fill($self, "publicinbox.$name");
 }
 
+sub lookup_ei {
+        my ($self, $name) = @_;
+        $self->{-ei_by_name}->{$name} //= _fill_ei($self, "eindex.$name");
+}
+
 sub each_inbox {
         my ($self, $cb, @arg) = @_;
         # may auto-vivify if config file is non-existent:
@@ -457,6 +462,13 @@ EOF
         $ibx
 }
 
+sub _fill_ei ($$) {
+        my ($self, $pfx) = @_;
+        require PublicInbox::ExtSearch;
+        my $d = $self->{"$pfx.topdir"};
+        defined($d) && -d $d ? PublicInbox::ExtSearch->new($d) : undef;
+}
+
 sub urlmatch {
         my ($self, $key, $url) = @_;
         state $urlmatch_broken; # requires git 1.8.5