]> Sergey Matveev's repositories - public-inbox.git/blob - lib/PublicInbox/ExtSearch.pm
extsearch: canonicalize topdir
[public-inbox.git] / lib / PublicInbox / ExtSearch.pm
1 # Copyright (C) 2020 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3
4 # Read-only external (detached) index for cross inbox search.
5 # This is a read-only counterpart to PublicInbox::ExtSearchIdx
6 # and behaves like PublicInbox::Inbox AND PublicInbox::Search
7 package PublicInbox::ExtSearch;
8 use strict;
9 use v5.10.1;
10 use PublicInbox::Over;
11 use PublicInbox::Inbox;
12 use File::Spec ();
13
14 # for ->reopen, ->mset, ->mset_to_artnums
15 use parent qw(PublicInbox::Search);
16
17 sub new {
18         my (undef, $topdir) = @_;
19         $topdir = File::Spec->canonpath($topdir);
20         bless {
21                 topdir => $topdir,
22                 # xpfx => 'ei15'
23                 xpfx => "$topdir/ei".PublicInbox::Search::SCHEMA_VERSION
24         }, __PACKAGE__;
25 }
26
27 sub search { $_[0] } # self
28
29 # overrides PublicInbox::Search::_xdb
30 sub _xdb {
31         my ($self) = @_;
32         $self->xdb_sharded;
33 }
34
35 # same as per-inbox ->over, for now...
36 sub over {
37         my ($self) = @_;
38         $self->{over} //= PublicInbox::Over->new("$self->{xpfx}/over.sqlite3");
39 }
40
41 sub git {
42         my ($self) = @_;
43         $self->{git} //= PublicInbox::Git->new("$self->{topdir}/ALL.git");
44 }
45
46 sub mm { undef }
47
48 sub altid_map { {} }
49
50 sub description {
51         my ($self) = @_;
52         ($self->{description} //=
53                 PublicInbox::Inbox::cat_desc("$self->{topdir}/description")) //
54                 '$EINDEX_DIR/description missing';
55 }
56
57 sub cloneurl { [] } # TODO
58
59 sub base_url { 'https://example.com/TODO/' }
60 sub nntp_url { [] }
61
62 no warnings 'once';
63 *smsg_eml = \&PublicInbox::Inbox::smsg_eml;
64 *smsg_by_mid = \&PublicInbox::Inbox::smsg_by_mid;
65 *msg_by_mid = \&PublicInbox::Inbox::msg_by_mid;
66 *modified = \&PublicInbox::Inbox::modified;
67 *recent = \&PublicInbox::Inbox::recent;
68
69 *max_git_epoch = *nntp_usable = *msg_by_path = \&mm; # undef
70
71 1;