summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlhchavez <lhchavez@lhchavez.com>2017-01-01 12:45:02 -0800
committerlhchavez <lhchavez@lhchavez.com>2017-01-01 12:46:37 -0800
commitdb535d0a7dfa3e5c2ded4a408234623b0241de00 (patch)
treee534c1b6cfc43b939910b76fa3f636c5bc9edb4e
parent75db289a041b1f1084768244e167b953ac7eeaa5 (diff)
downloadlibgit2-db535d0a7dfa3e5c2ded4a408234623b0241de00.tar.gz
Delete temporary packfile in indexer
This change deletes the temporary packfile that the indexer creates to avoid littering the pack/ directory with garbage.
-rw-r--r--src/indexer.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/indexer.c b/src/indexer.c
index a3a866989..27f49473a 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -151,6 +151,12 @@ cleanup:
if (fd != -1)
p_close(fd);
+ if (git_buf_is_allocated(&tmp_path))
+ (void)p_unlink(git_buf_cstr(&tmp_path));
+
+ if (idx->pack != NULL)
+ (void)p_unlink(idx->pack->pack_name);
+
git_buf_free(&path);
git_buf_free(&tmp_path);
git__free(idx);
@@ -1084,6 +1090,9 @@ 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. */
+ (void)p_unlink(idx->pack->pack_name);
+
if (!git_mutex_lock(&git__mwindow_mutex)) {
git_packfile_free(idx->pack);
git_mutex_unlock(&git__mwindow_mutex);