]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei_to_mail: Maildir: ensure link(2) succeeds
authorEric Wong <e@80x24.org>
Fri, 19 Feb 2021 00:58:31 +0000 (00:58 +0000)
committerEric Wong <e@80x24.org>
Fri, 19 Feb 2021 19:25:19 +0000 (19:25 +0000)
link(2) may fail with errors other than EEXIST; just bail out
since something is likely seriously wrong.

lib/PublicInbox/LeiToMail.pm

index f0adc44f23e6088b13e40d43b01fec9fa1705c7d..8a2d9471f032f45f3d2efba36678c46d13f7f2a9 100644 (file)
@@ -302,8 +302,9 @@ sub _buf2maildir {
                $rand = '';
                do {
                        $final = $dst.$rand.$common.':2,'.$sfx;
-               } while (!link($tmp, $final) && $! == EEXIST &&
+               } while (!($ok = link($tmp, $final)) && $! == EEXIST &&
                        ($rand = _rand.','));
+               die "link($tmp, $final): $!" unless $ok;
                unlink($tmp) or warn "W: failed to unlink $tmp: $!\n";
        } else {
                my $err = "Error writing $smsg->{blob} to $dst: $!\n";