Skip to content

Commit

Permalink
Remove the temp file if it is empty after the request has failed
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Nick Hengeveld authored and Junio C Hamano committed Nov 4, 2005
1 parent 2be8fd0 commit 50496b2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions http-fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 50496b2

Please sign in to comment.