]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiALE.pm
www_stream: extra link to mirroring information in the footer
[public-inbox.git] / lib / PublicInbox / LeiALE.pm
index bdb50a1a08a2b34b16531d5f9e1ca96f9ab1f404..cc9a2095af08e6b8f55145735ceb1e65c00cc44d 100644 (file)
@@ -11,16 +11,30 @@ 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;
+       my $sto = $lei->_lei_store;
+       $lxs->prepare_external($sto->search) if $sto;
+       for my $loc ($lei->externals_each) { # locals only
+               $lxs->prepare_external($loc) if -d $loc;
+       }
+       $self->refresh_externals($lxs, $lei);
+       $self;
 }
 
 sub over {} # undef for xoids_for
@@ -36,7 +50,7 @@ sub overs_all { # for xoids_for (called only in lei workers?)
 }
 
 sub refresh_externals {
-       my ($self, $lxs) = @_;
+       my ($self, $lxs, $lei) = @_;
        $self->git->cleanup;
        my $lk = $self->lock_for_scope;
        my $cur_lxs = ref($lxs)->new;
@@ -58,7 +72,7 @@ sub refresh_externals {
        }
        my @ibxish = $cur_lxs->locals;
        for my $x ($lxs->locals) {
-               my $d = File::Spec->canonpath($x->{inboxdir} // $x->{topdir});
+               my $d = $lei->canonpath_harder($x->{inboxdir} // $x->{topdir});
                $seen_ibxish{$d} //= do {
                        $new .= "$d\n";
                        push @ibxish, $x;
@@ -81,7 +95,7 @@ sub refresh_externals {
                $old = <$fh> // die "readline($f): $!";
        }
        for my $x (@ibxish) {
-               $new .= File::Spec->canonpath($x->git->{git_dir})."/objects\n";
+               $new .= $lei->canonpath_harder($x->git->{git_dir})."/objects\n";
        }
        $self->{ibxish} = \@ibxish;
        return if $old eq $new;