]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiInput.pm
lei: maildir: move shard support to MdirReader
[public-inbox.git] / lib / PublicInbox / LeiInput.pm
index c04fc2f84d1566bc1a609fe5b771d27ca3fb8761..e416d3ed6e1777b428e3db9039c689fffc7ad7ac 100644 (file)
@@ -5,6 +5,7 @@
 package PublicInbox::LeiInput;
 use strict;
 use v5.10.1;
+use PublicInbox::DS;
 
 sub check_input_format ($;$) {
        my ($lei, $files) = @_;
@@ -75,12 +76,19 @@ sub input_path_url {
                my $m = $lei->{opt}->{'lock'} //
                        PublicInbox::MboxLock->defaults;
                my $mbl = PublicInbox::MboxLock->acq($input, 0, $m);
+               my $zsfx = PublicInbox::MboxReader::zsfx($input);
+               if ($zsfx) {
+                       my $in = delete $mbl->{fh};
+                       $mbl->{fh} =
+                            PublicInbox::MboxReader::zsfxcat($in, $zsfx, $lei);
+               }
+               local $PublicInbox::DS::in_loop = 0 if $zsfx; # dwaitpid
                $self->input_fh($ifmt, $mbl->{fh}, $input, @args);
        } elsif (-d _ && (-d "$input/cur" || -d "$input/new")) {
                return $lei->fail(<<EOM) if $ifmt && $ifmt ne 'maildir';
 $input appears to a be a maildir, not $ifmt
 EOM
-               PublicInbox::MdirReader::maildir_each_eml($input,
+               PublicInbox::MdirReader->new->maildir_each_eml($input,
                                        $self->can('input_maildir_cb'),
                                        $self, @args);
        } else {
@@ -158,6 +166,14 @@ $input is `eml', not --in-format=$in_fmt
        $self->{inputs} = $inputs;
 }
 
+sub process_inputs {
+       my ($self) = @_;
+       for my $input (@{$self->{inputs}}) {
+               $self->input_path_url($input);
+       }
+       my $wait = $self->{lei}->{sto}->ipc_do('done') if $self->{lei}->{sto};
+}
+
 sub input_only_atfork_child {
        my ($self) = @_;
        my $lei = $self->{lei};