sha1_file.c (write_sha1_from_fd): Detect close failure.

I stumbled across this in the context of the fchmod 0444 patch.
At first, I was going to unlink and call error like the two subsequent
tests do, but a failed write (above) provokes a "die", so I made
this do the same.  This is testing for a write failure, after all.

Signed-off-by: Jim Meyering <jim@meyering.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
maint
Jim Meyering 2007-03-26 15:57:23 +02:00 committed by Junio C Hamano
parent e4d9516b21
commit 0d315468f3
1 changed files with 2 additions and 1 deletions

View File

@ -2155,7 +2155,8 @@ int write_sha1_from_fd(const unsigned char *sha1, int fd, char *buffer,
inflateEnd(&stream); inflateEnd(&stream);


fchmod(local, 0444); fchmod(local, 0444);
close(local); if (close(local) != 0)
die("unable to write sha1 file");
SHA1_Final(real_sha1, &c); SHA1_Final(real_sha1, &c);
if (ret != Z_STREAM_END) { if (ret != Z_STREAM_END) {
unlink(tmpfile); unlink(tmpfile);