my ($self) = @_;
$self->{ale} //= do {
require PublicInbox::LeiALE;
- PublicInbox::LeiALE->new(cache_dir($self).
- '/all_locals_ever.git');
+ $self->_lei_cfg(1)->{ale} //= PublicInbox::LeiALE->new($self);
};
}
use parent qw(PublicInbox::LeiSearch PublicInbox::Lock);
use PublicInbox::Git;
use PublicInbox::Import;
+use PublicInbox::LeiXSearch;
use Fcntl qw(SEEK_SET);
-sub new {
- my ($cls, $d) = @_;
+sub _new {
+ my ($d) = @_;
PublicInbox::Import::init_bare($d, 'ale');
bless {
git => PublicInbox::Git->new($d),
lock_path => "$d/lei_ale.state", # dual-duty lock + state
ibxish => [], # Inbox and ExtSearch (and LeiSearch) objects
- }, $cls;
+ }, __PACKAGE__
+}
+
+sub new {
+ my ($self, $lei) = @_;
+ ref($self) or $self = _new($lei->cache_dir . '/all_locals_ever.git');
+ my $lxs = PublicInbox::LeiXSearch->new;
+ $lxs->prepare_external($lei->_lei_store(1)->search);
+ for my $loc ($lei->externals_each) { # locals only
+ $lxs->prepare_external($loc) if -d $loc;
+ }
+ $self->refresh_externals($lxs);
+ $self;
}
sub over {} # undef for xoids_for
my $key = "external.$location.boost";
my $cur_boost = $cfg->{$key};
return if defined($cur_boost) && $cur_boost == $new_boost; # idempotent
- if (-d $location) {
- require PublicInbox::LeiXSearch;
- my $lxs = PublicInbox::LeiXSearch->new;
- $lxs->prepare_external($location);
- $self->ale->refresh_externals($lxs);
- }
$self->lei_config($key, $new_boost);
}
}
if ($opt->{'local'} //= scalar(@only) ? 0 : 1) {
$lxs->prepare_external($lse);
- } else {
- my $tmp = PublicInbox::LeiXSearch->new;
- $tmp->prepare_external($lse);
- $self->ale->refresh_externals($tmp);
}
if (@only) {
for my $loc (@only) {
my $mitem = ($mset->items)[0];
my $smsg = $lxs->smsg_for($mitem) or BAIL_OUT 'smsg_for broken';
- my $ale = PublicInbox::LeiALE->new("$home/ale");
+ my $ale = PublicInbox::LeiALE::_new("$home/ale");
$ale->refresh_externals($lxs);
my $exp = [ $smsg->{blob}, 'blob', -s 't/utf8.eml' ];
is_deeply([ $ale->git->check($smsg->{blob}) ], $exp, 'ale->git->check');