]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiALE.pm
lei: tie ALE lifetime to config file
[public-inbox.git] / lib / PublicInbox / LeiALE.pm
index bdb50a1a08a2b34b16531d5f9e1ca96f9ab1f404..45748435b53407995a66f337359b6833ba40eb6b 100644 (file)
@@ -11,16 +11,29 @@ use v5.10.1;
 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