create_tempfile: make sure that leading directories can be accessible by peers
[gitweb.git] / pack-write.c
index 665e2b29b8817aa6a8aa83ccd859ab51e7bb2234..f52cabe83829289dee7e44673b59a02db38918a5 100644 (file)
@@ -139,7 +139,7 @@ char *write_idx_file(char *index_name, struct pack_idx_entry **objects,
        }
 
        sha1write(f, sha1, 20);
-       sha1close(f, NULL, 1);
+       sha1close(f, NULL, CSUM_FSYNC);
        SHA1_Final(sha1, &ctx);
        return index_name;
 }
@@ -183,7 +183,6 @@ void fixup_pack_header_footer(int pack_fd,
 
 char *index_pack_lockfile(int ip_out)
 {
-       int len, s;
        char packname[46];
 
        /*
@@ -193,11 +192,8 @@ char *index_pack_lockfile(int ip_out)
         * case, we need it to remove the corresponding .keep file
         * later on.  If we don't get that then tough luck with it.
         */
-       for (len = 0;
-                len < 46 && (s = xread(ip_out, packname+len, 46-len)) > 0;
-                len += s);
-       if (len == 46 && packname[45] == '\n' &&
-               memcmp(packname, "keep\t", 5) == 0) {
+       if (read_in_full(ip_out, packname, 46) == 46 && packname[45] == '\n' &&
+           memcmp(packname, "keep\t", 5) == 0) {
                char path[PATH_MAX];
                packname[45] = 0;
                snprintf(path, sizeof(path), "%s/pack/pack-%s.keep",