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>
Nick Hengeveld committed
Nov 3, 2005 at 17:54 UTC
50496b2170cbe87b4c13f89f274aa2f181522bb9
1 file changed
+5
http-fetch.c
+5
@@ -520,12 +520,17 @@ static void start_request(struct transfer_request *request)
520
521
static void finish_request(struct transfer_request *request)
522
{
523
+ struct stat st;
524
+
525
fchmod(request->local, 0444);
526
close(request->local);
527
528
if (request->http_code == 416) {
529
fprintf(stderr, "Warning: requested range invalid; we may already have all the data.\n");
530
} else if (request->curl_result != CURLE_OK) {
531
+ if (stat(request->tmpfile, &st) == 0)
532
+ if (st.st_size == 0)
533
+ unlink(request->tmpfile);
534
return;
535
}
536