]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LEI.pm
www_stream: add trailing slash for help and color links
[public-inbox.git] / lib / PublicInbox / LEI.pm
index 59a3338c08a69a9415190546b122d06bc14eff3f..a0986f386a165de5690ded33bca4c3042df51898 100644 (file)
@@ -412,9 +412,9 @@ sub check_input_format ($;$) {
                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;
@@ -606,8 +606,10 @@ sub _lei_cfg ($;$) {
        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) {
@@ -625,6 +627,10 @@ 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'})) {
+               $cfg->{-lei_store} = $sto;
+       }
        $self->{cfg} = $PATH2CFG{$f} = $cfg;
 }