diff options
author | Eric Wong <e@80x24.org> | 2021-03-25 06:20:24 +0200 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-03-25 17:59:03 +0000 |
commit | c1b912dea25f48958434f1e85337029b0959fc83 (patch) | |
tree | 108147df9e3c723efc906b9afb7a5c2a1f23a54f /lib/PublicInbox/LeiImport.pm | |
parent | 64b1ce9f94127fc144d6205bb572fe43b4b552c2 (diff) | |
download | public-inbox-c1b912dea25f48958434f1e85337029b0959fc83.tar.gz |
"lei import" should never be without a {sto}, and *_done should not be called multiple times, so ensure we can fail if it's missing. Update some existing tests to complain loudly by introducing a handy "xbail" function which wraps "explain" and BAIL_OUT. BAIL_OUT was painful to type and concatenating the result of "explain" doesn't work as I thought it would since "explain" always returns an array, and BAIL_OUT only accepts a single scalar arg (unlike "die").
Diffstat (limited to 'lib/PublicInbox/LeiImport.pm')
-rw-r--r-- | lib/PublicInbox/LeiImport.pm | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/PublicInbox/LeiImport.pm b/lib/PublicInbox/LeiImport.pm index 9da6b7f9..7c5b7d09 100644 --- a/lib/PublicInbox/LeiImport.pm +++ b/lib/PublicInbox/LeiImport.pm @@ -39,14 +39,14 @@ sub import_done_wait { # dwaitpid callback my ($arg, $pid) = @_; my ($imp, $lei) = @$arg; $lei->child_error($?, 'non-fatal errors during import') if $?; - my $sto = delete $lei->{sto}; - my $wait = $sto->ipc_do('done') if $sto; # PublicInbox::LeiStore::done + my $sto = delete $lei->{sto} // return $lei->fail('BUG: {sto} gone'); + my $wait = $sto->ipc_do('done'); # PublicInbox::LeiStore::done $lei->dclose; } sub import_done { # EOF callback for main daemon my ($lei) = @_; - my $imp = delete $lei->{imp} or return; + my $imp = delete $lei->{imp} // return $lei->fail('BUG: {imp} gone'); $imp->wq_wait_old(\&import_done_wait, $lei); } |