]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei: improve idempotent "init" error message
authorEric Wong <e@80x24.org>
Mon, 4 Jan 2021 04:16:24 +0000 (04:16 +0000)
committerEric Wong <e@80x24.org>
Mon, 4 Jan 2021 19:00:48 +0000 (19:00 +0000)
Showing "leistore.dir= already initialized" because $cur is
undefined isn't useful.

lib/PublicInbox/LEI.pm

index 50453dde934551d4221651fbca26bebe2aa9038d..9a3b1ee35bb9c08f39d5bb003164080e026a3125 100644 (file)
@@ -505,7 +505,7 @@ sub lei_init {
        $dir //= _store_path($env);
        $dir = File::Spec->rel2abs($dir, $env->{PWD}); # PWD is symlink-aware
        my @cur = stat($cur) if defined($cur);
-       $cur = File::Spec->canonpath($cur) if $cur;
+       $cur = File::Spec->canonpath($cur // $dir);
        my @dir = stat($dir);
        my $exists = "I: leistore.dir=$cur already initialized" if @dir;
        if (@cur) {