]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiConvert.pm
lei_input: support compressed mboxes
[public-inbox.git] / lib / PublicInbox / LeiConvert.pm
index bc86fe25f249f8a51868bf5a5acb5cb6b4f411ef..fb7a2f3bf99c298288fb9e148fc0c00cf8cf4415 100644 (file)
@@ -34,7 +34,7 @@ sub input_maildir_cb {
 
 sub do_convert { # via wq_do
        my ($self) = @_;
-       $self->input_stdin;
+       $PublicInbox::DS::in_loop = 0; # force synchronous dwaitpid
        for my $input (@{$self->{inputs}}) {
                $self->input_path_url($input);
        }
@@ -46,16 +46,18 @@ sub lei_convert { # the main "lei convert" method
        my ($lei, @inputs) = @_;
        $lei->{opt}->{kw} //= 1;
        $lei->{opt}->{dedupe} //= 'none';
-       my $self = $lei->{cnv} = bless {}, __PACKAGE__;
+       my $self = bless {}, __PACKAGE__;
        my $ovv = PublicInbox::LeiOverview->new($lei, 'out-format');
        $lei->{l2m} or return
                $lei->fail("output not specified or is not a mail destination");
-       $lei->{opt}->{augment} = 1 unless $ovv->{dst} eq '/dev/stdout';
+       my $devfd = $lei->path_to_fd($ovv->{dst}) // return;
+       $lei->{opt}->{augment} = 1 if $devfd < 0;
        $self->prepare_inputs($lei, \@inputs) or return;
-       my $op = $lei->workers_start($self, 'lei_convert', 1);
+       my ($op_c, $ops) = $lei->workers_start($self, 'lei_convert', 1);
+       $lei->{cnv} = $self;
        $self->wq_io_do('do_convert', []);
        $self->wq_close(1);
-       while ($op && $op->{sock}) { $op->event_step }
+       $op_c->op_wait_event($ops);
 }
 
 sub ipc_atfork_child {