| 371 | } |
| 372 | |
| 373 | void generated_pack_install(struct generated_pack *pack, const char *name, |
| 374 | const char *packdir, const char *packtmp) |
| 375 | { |
| 376 | size_t ext; |
| 377 | for (ext = 0; ext < ARRAY_SIZE(exts); ext++) { |
| 378 | char *fname; |
| 379 | |
| 380 | fname = mkpathdup("%s/pack-%s%s", packdir, name, |
| 381 | exts[ext].name); |
| 382 | |
| 383 | if (pack->tempfiles[ext]) { |
| 384 | const char *fname_old = get_tempfile_path(pack->tempfiles[ext]); |
| 385 | struct stat statbuffer; |
| 386 | |
| 387 | if (!stat(fname_old, &statbuffer)) { |
| 388 | statbuffer.st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH); |
| 389 | chmod(fname_old, statbuffer.st_mode); |
| 390 | } |
| 391 | |
| 392 | if (rename_tempfile(&pack->tempfiles[ext], fname)) |
| 393 | die_errno(_("renaming pack to '%s' failed"), |
| 394 | fname); |
| 395 | } else if (!exts[ext].optional) |
| 396 | die(_("pack-objects did not write a '%s' file for pack %s-%s"), |
| 397 | exts[ext].name, packtmp, name); |
| 398 | else if (unlink(fname) < 0 && errno != ENOENT) |
| 399 | die_errno(_("could not unlink: %s"), fname); |
| 400 | |
| 401 | free(fname); |
| 402 | } |
| 403 | } |
no test coverage detected