]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
lei_to_mail: don't close STDOUT unless it is a mbox* output
authorEric Wong <e@80x24.org>
Wed, 22 Nov 2023 00:13:31 +0000 (00:13 +0000)
committerEric Wong <e@80x24.org>
Wed, 22 Nov 2023 01:03:05 +0000 (01:03 +0000)
We only care about error checking when stdout is an mbox output
pointed to a pathname.  This is noticeable with `lei up' with
multiple non-mbox* destinations.  We'll also ensure throwing
exceptions to trigger lei->x_it from lei->do_env results in the
epoll/kqueue watch being discarded, otherwise commands may never
terminate (leading to stuck tests)

lib/PublicInbox/LEI.pm
lib/PublicInbox/LeiToMail.pm
t/lei-q-save.t

index 8d235b372a1b78c5597d6b6d20e143d8b8760833..86b71fcd6931b32f5d875a21426664a0da7da4d4 100644 (file)
@@ -493,6 +493,7 @@ sub x_it ($$) {
        } elsif ($quit == \&CORE::exit) { # an admin (one-shot) command
                exit($code >> 8);
        } # else ignore if client disconnected
+       $self->dclose if $$ == $daemon_pid;
 }
 
 sub err ($;@) {
index 007191bbcbef73afe2243b3169e68377fd8a2dd3..a930fc30b512f7ce93abe08869b7fc365906ccde 100644 (file)
@@ -612,8 +612,8 @@ sub _pre_augment_mbox {
 sub finish_output {
        my ($self, $lei) = @_;
        my $out = delete $lei->{1} // die 'BUG: no lei->{1}';
-       my $old = delete $lei->{old_1};
-       $lei->{1} = $old if $old;
+       my $old = delete $lei->{old_1} or return; # path only
+       $lei->{1} = $old;
        return if $out->close; # reaps gzip|pigz|xz|bzip2
        my $msg = "E: Error closing $lei->{ovv}->{dst}";
        $? ? $lei->child_error($?) : ($msg .= " ($!)");
index a9f9d4d6168293411cbf8f2b2da0bd5081492f90..0970bc3c14e7f0aad42dc71cd4c91fddaf894dfb 100644 (file)
@@ -305,5 +305,7 @@ EOM
        is(scalar(@new), 2, 'got new message');
        is_xdeeply([grep { $_ eq $orig[0] } @new], \@orig,
                'original message preserved on up w/ threads');
+       lei_ok 'up', "$home/md", $d, \'multiple maildir up';
+       unlike $lei_err, qr! line \d+!s, 'no warnings';
 });
 done_testing;