]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei_store: initialize IPC lock properly
authorEric Wong <e@80x24.org>
Sat, 20 Mar 2021 02:38:00 +0000 (07:38 +0500)
committerEric Wong <e@80x24.org>
Sat, 20 Mar 2021 02:48:02 +0000 (02:48 +0000)
This was causing errors in a mass keyword import patch
I'm working on.

lib/PublicInbox/IPC.pm
lib/PublicInbox/LEI.pm
lib/PublicInbox/LeiStore.pm

index 1fa67d00e704baff9b769a12ab25487a9cf1d774..cf3723f764b9f3c84b33a8bdf2993a117ec75e63 100644 (file)
@@ -177,6 +177,7 @@ sub ipc_worker_stop {
 # and writing to the same store
 sub ipc_lock_init {
        my ($self, $f) = @_;
+       $f // die 'BUG: no filename given';
        require PublicInbox::Lock;
        $self->{-ipc_lock} //= bless { lock_path => $f }, 'PublicInbox::Lock'
 }
index a0986f386a165de5690ded33bca4c3042df51898..d20ba7448663ddf6a28e18625245264bd5d9c94b 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')
@@ -188,7 +188,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 +640,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 +689,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);
index ae2639148918d6fc741c75f4039fdd01568021c7..26f975c307402535643432389f45c4ceb7e6638a 100644 (file)
@@ -261,7 +261,7 @@ sub write_prepare {
        my ($self, $lei) = @_;
        unless ($self->{-ipc_req}) {
                require PublicInbox::LeiXSearch;
-               $self->ipc_lock_init;
+               $self->ipc_lock_init($lei->store_path . '/ipc.lock');
                # Mail we import into lei are private, so headers filtered out
                # by -mda for public mail are not appropriate
                local @PublicInbox::MDA::BAD_HEADERS = ();