create_tempfile: make sure that leading directories can be accessible by peers

In a shared repository, we should make sure adjust_shared_perm() is called
after creating the initial fan-out directories under objects/ directory.

Earlier an logico called the function only when mkdir() failed; we should
do so when mkdir() succeeded.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano 2008-06-16 22:02:12 -07:00
Родитель 1421c5f274
Коммит 3bfaf01857
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -2125,7 +2125,7 @@ static int create_tmpfile(char *buffer, size_t bufsiz, const char *filename)
if (fd < 0 && dirlen) {
/* Make sure the directory exists */
buffer[dirlen-1] = 0;
if (mkdir(buffer, 0777) && adjust_shared_perm(buffer))
if (mkdir(buffer, 0777) || adjust_shared_perm(buffer))
return -1;
/* Try again */