about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-03-26 06:29:36 +0200
committerEric Wong <e@80x24.org>2021-03-26 19:58:35 +0000
commit37dfb2c0d3c60277567325c15d5695b2dee03ad1 (patch)
tree602bf043b2fe67a7c34bf054fac0464e8d255bd0
parentc1e8f5b1a5da1606871f39d4ea260949b6611177 (diff)
downloadpublic-inbox-37dfb2c0d3c60277567325c15d5695b2dee03ad1.tar.gz
Perhaps leistore.dir doesn't need to have a config file
entry if we're using the default location.

v2: "account for unconfigured leistore.dir" (on reuse)
-rw-r--r--lib/PublicInbox/LEI.pm9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index d534f1d0..99e180f6 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -701,8 +701,9 @@ sub _lei_cfg ($;$) {
         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'})) {
+        if ($sto && File::Spec->canonpath($sto_dir // store_path($self))
+                        eq File::Spec->canonpath($cfg->{'leistore.dir'} //
+                                                store_path($self))) {
                 $cfg->{-lei_store} = $sto;
         }
         if (scalar(keys %PATH2CFG) > 5) {
@@ -719,8 +720,8 @@ sub _lei_store ($;$) {
         my $cfg = _lei_cfg($self, $creat);
         $cfg->{-lei_store} //= do {
                 require PublicInbox::LeiStore;
-                my $dir = $cfg->{'leistore.dir'};
-                $dir //= $creat ? store_path($self) : return;
+                my $dir = $cfg->{'leistore.dir'} // store_path($self);
+                return unless $creat || -d $dir;
                 PublicInbox::LeiStore->new($dir, { creat => $creat });
         };
 }