From: Eric Wong Date: Tue, 8 Jul 2025 03:54:07 +0000 (+0000) Subject: lei_mail_sync: fix size check for Maildir||MH files X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;p=thirdparty%2Fpublic-inbox.git lei_mail_sync: fix size check for Maildir||MH files `-s $fh' returns undef only when a file is non-existent and zero when it's empty. Thus so we must use `||' to skip empty files. Furthermore, `-s FILEHANDLE' is never undef on open handles. Fixes: 5aab49f3 (lei: support reading MH for convert+import+index, 2023-12-29) --- diff --git a/lib/PublicInbox/LeiMailSync.pm b/lib/PublicInbox/LeiMailSync.pm index cab5bbb38..5bd5fb48d 100644 --- a/lib/PublicInbox/LeiMailSync.pm +++ b/lib/PublicInbox/LeiMailSync.pm @@ -460,7 +460,7 @@ WHERE b.oidbin = ? my $f = "$d/$x/$n"; open my $fh, '<', $f or next; # some (buggy) Maildir writers are non-atomic: - my $raw = read_all($fh, -s $fh // next); + my $raw = read_all($fh, -s $fh || next); next if $vrfy && blob_mismatch $f, $oidhex, \$raw; return \$raw; } @@ -478,7 +478,7 @@ WHERE b.oidbin = ? AND f.loc REGEXP '^mh:/' $f =~ s/\Amh://s or die "BUG: not MH: $f"; $f .= "/$n"; open my $fh, '<', $f or next; - my $raw = read_all($fh, -s $fh // next); + my $raw = read_all($fh, -s $fh || next); next if blob_mismatch $f, $oidhex, \$raw; return \$raw; }