зеркало из https://github.com/microsoft/git.git
Merge branch 'sp/lazy-mkdir'
* sp/lazy-mkdir: Make lazy mkdir more robust.
This commit is contained in:
Коммит
1733832d8e
|
@ -1331,21 +1331,20 @@ char *write_sha1_file_prepare(void *buf,
|
|||
static int link_temp_to_file(const char *tmpfile, char *filename)
|
||||
{
|
||||
int ret;
|
||||
char *dir;
|
||||
|
||||
if (!link(tmpfile, filename))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Try to mkdir the last path component if that failed
|
||||
* with an ENOENT.
|
||||
* Try to mkdir the last path component if that failed.
|
||||
*
|
||||
* Re-try the "link()" regardless of whether the mkdir
|
||||
* succeeds, since a race might mean that somebody
|
||||
* else succeeded.
|
||||
*/
|
||||
ret = errno;
|
||||
if (ret == ENOENT) {
|
||||
char *dir = strrchr(filename, '/');
|
||||
dir = strrchr(filename, '/');
|
||||
if (dir) {
|
||||
*dir = 0;
|
||||
mkdir(filename, 0777);
|
||||
|
@ -1356,7 +1355,6 @@ static int link_temp_to_file(const char *tmpfile, char *filename)
|
|||
return 0;
|
||||
ret = errno;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче