]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
lei_mail_sync: fix size check for Maildir||MH files master
authorEric Wong <e@80x24.org>
Tue, 8 Jul 2025 03:54:07 +0000 (03:54 +0000)
committerEric Wong <e@80x24.org>
Wed, 9 Jul 2025 21:06:41 +0000 (21:06 +0000)
`-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)
lib/PublicInbox/LeiMailSync.pm

index cab5bbb3814c4fd9b2e782288fd424e5f86872c4..5bd5fb48db94e73ebb48ea2df312beae08d94480 100644 (file)
@@ -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;
        }