]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LEI.pm
lei: All Local Externals: bare git dir for alternates
[public-inbox.git] / lib / PublicInbox / LEI.pm
index a0986f386a165de5690ded33bca4c3042df51898..0da26a32825755c7f3534d2c50b9c70e04fc06f0 100644 (file)
@@ -83,7 +83,7 @@ sub rel2abs ($$) {
        File::Spec->rel2abs($p, $pwd);
 }
 
-sub _store_path ($) {
+sub store_path ($) {
        my ($self) = @_;
        rel2abs($self, ($self->{env}->{XDG_DATA_HOME} //
                ($self->{env}->{HOME} // '/nonexistent').'/.local/share')
@@ -97,6 +97,22 @@ sub _config_path ($) {
                .'/lei/config');
 }
 
+sub cache_dir ($) {
+       my ($self) = @_;
+       rel2abs($self, ($self->{env}->{XDG_CACHE_HOME} //
+               ($self->{env}->{HOME} // '/nonexistent').'/.cache')
+               .'/lei');
+}
+
+sub ale {
+       my ($self) = @_;
+       $self->{ale} //= do {
+               require PublicInbox::LeiALE;
+               PublicInbox::LeiALE->new(cache_dir($self).
+                                       '/all_locals_ever.git');
+       };
+}
+
 sub index_opt {
        # TODO: drop underscore variants everywhere, they're undocumented
        qw(fsync|sync! jobs|j=i indexlevel|L=s compact
@@ -188,7 +204,7 @@ our %CMD = ( # sorted in order of importance/use:
        }, qw(config-file|system|global|file|f=s), # for conflict detection
         qw(C=s@), pass_through('git config') ],
 'init' => [ '[DIRNAME]', sub {
-       "initialize storage, default: "._store_path($_[0]);
+       "initialize storage, default: ".store_path($_[0]);
        }, qw(quiet|q C=s@) ],
 'daemon-kill' => [ '[-SIGNAL]', 'signal the lei-daemon',
        # "-C DIR" conflicts with -CHLD, here, and chdir makes no sense, here
@@ -640,7 +656,7 @@ sub _lei_store ($;$) {
        $cfg->{-lei_store} //= do {
                require PublicInbox::LeiStore;
                my $dir = $cfg->{'leistore.dir'};
-               $dir //= $creat ? _store_path($self) : return;
+               $dir //= $creat ? store_path($self) : return;
                PublicInbox::LeiStore->new($dir, { creat => $creat });
        };
 }
@@ -689,7 +705,7 @@ sub lei_init {
        my ($self, $dir) = @_;
        my $cfg = _lei_cfg($self, 1);
        my $cur = $cfg->{'leistore.dir'};
-       $dir //= _store_path($self);
+       $dir //= store_path($self);
        $dir = rel2abs($self, $dir);
        my @cur = stat($cur) if defined($cur);
        $cur = File::Spec->canonpath($cur // $dir);