Skip to content

Commit

Permalink
sha1_file: make the new sha1 object writing be coda-friendly.
Browse files Browse the repository at this point in the history
Coda doesn't like cross-directory hardlinks. So try to fall back
on a plain rename instead.
  • Loading branch information
Linus Torvalds committed May 3, 2005
1 parent aac1794 commit a31c6d0
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,21 @@ int write_sha1_file(char *buf, unsigned long len, const char *type, unsigned cha
close(fd);

ret = link(tmpfile, filename);
if (ret < 0)
if (ret < 0) {
ret = errno;

/*
* Coda hack - coda doesn't like cross-directory links,
* so we fall back to a rename, which will mean that it
* won't be able to check collisions, but that's not a
* big deal.
*
* When this succeeds, we just return 0. We have nothing
* left to unlink.
*/
if (ret == EXDEV && !rename(tmpfile, filename))
return 0;
}
unlink(tmpfile);
if (ret) {
if (ret != EEXIST) {
Expand Down

0 comments on commit a31c6d0

Please sign in to comment.