Close the file before unlinking

I forgot that Windows chokes while trying to delete open files.
This commit is contained in:
lhchavez 2017-01-03 19:15:09 -08:00
parent a7ff6e5e5e
commit 96df833b63

View File

@ -1091,6 +1091,12 @@ void git_indexer_free(git_indexer *idx)
git_vector_free_deep(&idx->deltas);
/* Try to delete the temporary file in case it was not committed. */
git_mwindow_free_all(&idx->pack->mwf);
/* We need to close the descriptor here so Windows doesn't choke on unlink */
if (idx->pack->mwf.fd != -1) {
(void)p_close(idx->pack->mwf.fd);
idx->pack->mwf.fd = -1;
}
(void)p_unlink(idx->pack->pack_name);
if (!git_mutex_lock(&git__mwindow_mutex)) {