aboutsummaryrefslogtreecommitdiff
path: root/http-fetch.c
diff options
context:
space:
mode:
authorNick Hengeveld <nickh@reactrix.com>2005-11-03 17:54:52 -0800
committerJunio C Hamano <junkio@cox.net>2005-11-03 18:35:18 -0800
commit50496b2170cbe87b4c13f89f274aa2f181522bb9 (patch)
treeae0ef8bb9e863ca3ea82f68d1eafc6f37bf23310 /http-fetch.c
parent2be8fd085e865097fa0908fe1a94c8edf9cde7f5 (diff)
downloadgit-50496b2170cbe87b4c13f89f274aa2f181522bb9.tar.gz
git-50496b2170cbe87b4c13f89f274aa2f181522bb9.tar.xz
Remove the temp file if it is empty after the request has failed
After using cg-update to pull, empty files named *.temp are left in the various subdirectories of .git/objects/. These are created by git-http-fetch to hold data as it's being fetched from the remote repository. They are left behind after a transfer error so that the next time git-http-fetch runs it can pick up where it left off. If they're empty though, it would make more sense to delete them rather than leaving them behind for the next attempt. Signed-off-by: Nick Hengeveld <nickh@reactrix.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'http-fetch.c')
-rw-r--r--http-fetch.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/http-fetch.c b/http-fetch.c
index a1b03cd9c..b12779dcb 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -520,12 +520,17 @@ static void start_request(struct transfer_request *request)
static void finish_request(struct transfer_request *request)
{
+ struct stat st;
+
fchmod(request->local, 0444);
close(request->local);
if (request->http_code == 416) {
fprintf(stderr, "Warning: requested range invalid; we may already have all the data.\n");
} else if (request->curl_result != CURLE_OK) {
+ if (stat(request->tmpfile, &st) == 0)
+ if (st.st_size == 0)
+ unlink(request->tmpfile);
return;
}