-sub _import_fh {
- my ($lei, $fh, $input, $ifmt) = @_;
- my $kw = $lei->{opt}->{kw} ?
- PublicInbox::MboxReader->can('mbox_keywords') : undef;
- 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, $kw);
- } else { # some mbox (->can already checked in call);
- my $cb = PublicInbox::MboxReader->reads($ifmt) //
- die "BUG: bad fmt=$ifmt";
- $cb->(undef, $fh, \&_import_eml, $lei, $kw);
- }
- };
- $lei->child_error(1 << 8, "$input: $@") if $@;
-}
-