FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Merge pull request #4085 from libgit2/ethomson/packfile_close · libgit2/libgit2@176f555 · GitHub

Repository navigation

Commit 176f555

Browse files
Edward Thomson
authored
Merge pull request #4085 from libgit2/ethomson/packfile_close
indexer: introduce `git_packfile_close`
2 parents 98f5387 + 87b7a70 commit 176f555

3 files changed

Lines changed: 18 additions & 15 deletions

File tree

‎src/indexer.c‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ void git_indexer_free(git_indexer *idx)
10811081

10821082
git_vector_free_deep(&idx->objects);
10831083

1084-
if (idx->pack && idx->pack->idx_cache) {
1084+
if (idx->pack->idx_cache) {
10851085
struct git_pack_entry *pentry;
10861086
kh_foreach_value(
10871087
idx->pack->idx_cache, pentry, { git__free(pentry); });
@@ -1091,17 +1091,10 @@ void git_indexer_free(git_indexer *idx)
10911091

10921092
git_vector_free_deep(&idx->deltas);
10931093

1094-
/* Try to delete the temporary file in case it was not committed. */
1095-
git_mwindow_free_all(&idx->pack->mwf);
1096-
1097-
/* We need to close the descriptor here so Windows doesn't choke on unlink */
1098-
if (idx->pack->mwf.fd != -1)
1099-
p_close(idx->pack->mwf.fd);
1100-
1101-
if (!idx->pack_committed)
1102-
p_unlink(idx->pack->pack_name);
1103-
11041094
if (!git_mutex_lock(&git__mwindow_mutex)) {
1095+
if (!idx->pack_committed)
1096+
git_packfile_close(idx->pack, true);
1097+
11051098
git_packfile_free(idx->pack);
11061099
git_mutex_unlock(&git__mwindow_mutex);
11071100
}

‎src/pack.c‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -991,17 +991,26 @@ git_off_t get_delta_base(
991991
*
992992
***********************************************************/
993993

994+
void git_packfile_close(struct git_pack_file *p, bool unlink_packfile)
995+
{
996+
if (p->mwf.fd >= 0) {
997+
git_mwindow_free_all_locked(&p->mwf);
998+
p_close(p->mwf.fd);
999+
p->mwf.fd = -1;
1000+
}
1001+
1002+
if (unlink_packfile)
1003+
p_unlink(p->pack_name);
1004+
}
1005+
9941006
void git_packfile_free(struct git_pack_file *p)
9951007
{
9961008
if (!p)
9971009
return;
9981010

9991011
cache_free(&p->bases);
10001012

1001-
if (p->mwf.fd >= 0) {
1002-
git_mwindow_free_all_locked(&p->mwf);
1003-
p_close(p->mwf.fd);
1004-
}
1013+
git_packfile_close(p, false);
10051014

10061015
pack_index_free(p);
10071016

‎src/pack.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ git_off_t get_delta_base(struct git_pack_file *p, git_mwindow **w_curs,
149149
git_off_t *curpos, git_otype type,
150150
git_off_t delta_obj_offset);
151151

152+
void git_packfile_close(struct git_pack_file *p, bool unlink_packfile);
152153
void git_packfile_free(struct git_pack_file *p);
153154
int git_packfile_alloc(struct git_pack_file **pack_out, const char *path);
154155

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL