From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 9C8541F9FC; Fri, 26 Mar 2021 23:07:12 +0000 (UTC) Date: Fri, 26 Mar 2021 23:07:11 +0000 From: Eric Wong To: meta@public-inbox.org Subject: [SQUASH] account for /dev/* FDs in prepare_inputs, too Message-ID: References: <20210326095126.8184-1-e@80x24.org> <20210326095126.8184-4-e@80x24.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210326095126.8184-4-e@80x24.org> List-Id: This is needed for t/lei-import.t on FreeBSD, it should be necessary on Linux, but I didn't notice problems there... diff --git a/lib/PublicInbox/LeiInput.pm b/lib/PublicInbox/LeiInput.pm index eed0eed7..d916249a 100644 --- a/lib/PublicInbox/LeiInput.pm +++ b/lib/PublicInbox/LeiInput.pm @@ -113,21 +113,29 @@ sub prepare_inputs { # returns undef on error --in-format=$in_fmt and `$ifmt:' conflict } - if (-f $input_path) { + my $devfd = $lei->path_to_fd($input_path) // return; + if ($devfd >= 0 || (-f $input_path || -p _)) { require PublicInbox::MboxLock; require PublicInbox::MboxReader; PublicInbox::MboxReader->reads($ifmt) or return $lei->fail("$ifmt not supported"); - } elsif (-d _) { + } elsif (-d $input_path) { require PublicInbox::MdirReader; $ifmt eq 'maildir' or return $lei->fail("$ifmt not supported"); } else { return $lei->fail("Unable to handle $input"); } - } elsif (-f $input) { push @f, $input } - elsif (-d _) { push @d, $input } - else { return $lei->fail("Unable to handle $input") } + } else { + my $devfd = $lei->path_to_fd($input) // return; + if ($devfd >= 0 || -f $input || -p _) { + push @f, $input + } elsif (-d $input) { + push @d, $input + } else { + return $lei->fail("Unable to handle $input") + } + } } if (@f) { check_input_format($lei, \@f) or return } if (@d) { # TODO: check for MH vs Maildir, here