This is merely to avoid perl setting errors internally which
were not user visible. The double-close wasn't a problem in
practice since we open a new file hanlde for the mbox or
mbox.gz anyways, so the new t/lei-up.t test case shows no
regressions nor fixes.
---
MANIFEST | 1 +
lib/PublicInbox/LeiUp.pm | 4 ++++
t/lei-up.t | 39 +++++++++++++++++++++++++++++++++++++++
3 files changed, 44 insertions(+)
create mode 100644 t/lei-up.t
diff --git a/MANIFEST b/MANIFEST
index be6ec927..fad29622 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -443,6 +443,7 @@ t/lei-q-save.t
t/lei-q-thread.t
t/lei-sigpipe.t
t/lei-tag.t
+t/lei-up.t
t/lei-watch.t
t/lei.t
t/lei_dedupe.t
diff --git a/lib/PublicInbox/LeiUp.pm b/lib/PublicInbox/LeiUp.pm
index e1da64aa..a39d6047 100644
--- a/lib/PublicInbox/LeiUp.pm
+++ b/lib/PublicInbox/LeiUp.pm
@@ -54,6 +54,10 @@ sub up1_redispatch {
$l->{opt} = { %{$l->{opt}} };
delete $l->{sock};
$l->{''} = $op_p; # daemon only
+
+ # make close($l->{1}) happy in lei->dclose
+ open my $fh, '>&', $l->{1} or return $l->child_error(0, "dup: $!");
+ $l->{1} = $fh;
eval {
$l->qerr("# updating $out");
up1($l, $out);
diff --git a/t/lei-up.t b/t/lei-up.t
new file mode 100644
index 00000000..c6f31c74
--- /dev/null
+++ b/t/lei-up.t
@@ -0,0 +1,39 @@
+#!perl -w
+# Copyright all contributors <[email protected]>
+# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
+use strict; use v5.10.1; use PublicInbox::TestCommon;
+my ($ro_home, $cfg_path) = setup_public_inboxes;
+use IO::Uncompress::Gunzip qw(gunzip $GunzipError);
+test_lei(sub {
+ my $s = eml_load('t/plack-qp.eml')->as_string;
+ lei_ok [qw(import -q -F eml -)], undef, { 0 => \$s, %$lei_opt };
+ lei_ok qw(q z:0.. -f mboxcl2 -o), "$ENV{HOME}/a.mbox.gz";
+ lei_ok qw(q z:0.. -f mboxcl2 -o), "$ENV{HOME}/b.mbox.gz";
+ lei_ok qw(q z:0.. -f mboxcl2 -o), "$ENV{HOME}/a";
+ lei_ok qw(q z:0.. -f mboxcl2 -o), "$ENV{HOME}/b";
+ lei_ok qw(ls-search);
+ $s = eml_load('t/utf8.eml')->as_string;
+ lei_ok [qw(import -q -F eml -)], undef, { 0 => \$s, %$lei_opt };
+ lei_ok qw(up --all=local);
+ open my $fh, "$ENV{HOME}/a.mbox.gz" or xbail "open: $!";
+ my $gz = do { local $/; <$fh> };
+ my $uc;
+ gunzip(\$gz => \$uc, MultiStream => 1) or xbail "gunzip $GunzipError";
+ open $fh, "$ENV{HOME}/a" or xbail "open: $!";
+
+ my $exp = do { local $/; <$fh> };
+ is($uc, $exp, 'compressed and uncompressed match (a.gz)');
+ like($exp, qr/testmessage\@example.com/, '2nd message added');
+ open $fh, "$ENV{HOME}/b.mbox.gz" or xbail "open: $!";
+
+ $gz = do { local $/; <$fh> };
+ undef $uc;
+ gunzip(\$gz => \$uc, MultiStream => 1) or xbail "gunzip $GunzipError";
+ is($uc, $exp, 'compressed and uncompressed match (b.gz)');
+
+ open $fh, "$ENV{HOME}/b" or xbail "open: $!";
+ $uc = do { local $/; <$fh> };
+ is($uc, $exp, 'uncompressed both match');
+});
+
+done_testing;
--
unsubscribe: one-click, see List-Unsubscribe header
archive: https://public-inbox.org/meta/