about summary refs log tree commit homepage
path: root/lib/PublicInbox/InboxWritable.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-10-17 23:37:52 +0000
committerEric Wong <e@80x24.org>2023-10-18 20:50:24 +0000
commit19b791f4894efcb6e545a6b51c8147298363358f (patch)
tree16a806fcb0c8fdaef242a2d268a8b1416809b46f /lib/PublicInbox/InboxWritable.pm
parent35b0f7aa00a24f5d89b1b941ec644327ba074c99 (diff)
downloadpublic-inbox-19b791f4894efcb6e545a6b51c8147298363358f.tar.gz
`readline' ops may not detect errors on partial reads.
This saves us some code to reduce cognitive overhead for
readers.  We'll also support reusing a destination buffers so it
can work more nicely with existing code.
Diffstat (limited to 'lib/PublicInbox/InboxWritable.pm')
-rw-r--r--lib/PublicInbox/InboxWritable.pm6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/PublicInbox/InboxWritable.pm b/lib/PublicInbox/InboxWritable.pm
index 65952aa2..6af72e71 100644
--- a/lib/PublicInbox/InboxWritable.pm
+++ b/lib/PublicInbox/InboxWritable.pm
@@ -7,6 +7,7 @@ use strict;
 use v5.10.1;
 use parent qw(PublicInbox::Inbox PublicInbox::Umask Exporter);
 use PublicInbox::Import;
+use PublicInbox::Git qw(read_all);
 use PublicInbox::Filter::Base qw(REJECT);
 use Errno qw(ENOENT);
 our @EXPORT_OK = qw(eml_from_path);
@@ -114,9 +115,8 @@ sub filter {
 sub eml_from_path ($) {
         my ($path) = @_;
         if (sysopen(my $fh, $path, O_RDONLY|O_NONBLOCK)) {
-                return unless -f $fh; # no FIFOs or directories
-                my $str = do { local $/; <$fh> } or return;
-                PublicInbox::Eml->new(\$str);
+                return unless -f $fh && -s _; # no FIFOs or directories
+                PublicInbox::Eml->new(\(my $str = read_all($fh, -s _)));
         } else { # ENOENT is common with Maildir
                 warn "failed to open $path: $!\n" if $! != ENOENT;
                 undef;