- } elsif (-f $input) { push @f, $input
- } elsif (-d _) { push @d, $input
- } else { return $lei->fail("Unable to handle $input") }
- }
- if (@f) { $lei->check_input_format(\@f) or return }
- if (@d) { # TODO: check for MH vs Maildir, here
- require PublicInbox::MdirReader;
- }
- $self->{inputs} = \@inputs;
- return import_start($lei) if !$nrd;
-
- if (my $err = $nrd->errors) {
- return $lei->fail($err);
- }
- $nrd->{quiet} = $lei->{opt}->{quiet};
- $lei->{nrd} = $nrd;
- require PublicInbox::LeiAuth;
- my $auth = $lei->{auth} = PublicInbox::LeiAuth->new($nrd);
- $auth->auth_start($lei, \&import_start, $lei);
-}
-
-sub ipc_atfork_child {
- my ($self) = @_;
- delete $self->{lei}->{imp}; # drop circular ref
- $self->{lei}->lei_atfork_child;
- $self->SUPER::ipc_atfork_child;
-}
-
-sub _import_fh {
- my ($lei, $fh, $input, $ifmt) = @_;
- my $set_kw = $lei->{opt}->{kw};
- eval {
- if ($ifmt eq 'eml') {
- my $buf = do { local $/; <$fh> } //
- return $lei->child_error(1 << 8, <<"");
-error reading $input: $!
-
- my $eml = PublicInbox::Eml->new(\$buf);
- _import_eml($eml, $lei->{sto}, $set_kw);
- } else { # some mbox (->can already checked in call);
- my $cb = PublicInbox::MboxReader->can($ifmt) //
- die "BUG: bad fmt=$ifmt";
- $cb->(undef, $fh, \&_import_eml, $lei->{sto}, $set_kw);