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')
.'/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
}, 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
return fail($self, "--$opt_key unset for $err");
}
require PublicInbox::MboxLock if $files;
+ require PublicInbox::MboxReader;
return 1 if $fmt eq 'eml';
# XXX: should this handle {gz,bz2,xz}? that's currently in LeiToMail
- require PublicInbox::MboxReader;
PublicInbox::MboxReader->can($fmt) or
return fail($self, "--$opt_key=$fmt unrecognized");
1;
my $f = _config_path($self);
my @st = stat($f);
my $cur_st = @st ? pack('dd', $st[10], $st[7]) : ''; # 10:ctime, 7:size
+ my ($sto, $sto_dir);
if (my $cfg = $PATH2CFG{$f}) { # reuse existing object in common case
return ($self->{cfg} = $cfg) if $cur_st eq $cfg->{-st};
+ ($sto, $sto_dir) = @$cfg{qw(-lei_store leistore.dir)};
}
if (!@st) {
unless ($creat) {
bless $cfg, 'PublicInbox::Config';
$cfg->{-st} = $cur_st;
$cfg->{'-f'} = $f;
+ if ($sto && File::Spec->canonpath($sto_dir) eq
+ File::Spec->canonpath($cfg->{'leistore.dir'})) {
+ $cfg->{-lei_store} = $sto;
+ }
$self->{cfg} = $PATH2CFG{$f} = $cfg;
}
$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 });
};
}
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);