Skip to content

Commit

Permalink
Fix for http-fetch from file:// URLs
Browse files Browse the repository at this point in the history
Recognize missing files when using http-fetch with file:// URLs

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 Dec 22, 2005
1 parent e99fcf9 commit a14c225
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions http-fetch.c
Expand Up @@ -267,7 +267,8 @@ static void process_object_response(void *callback_data)
obj_req->state = COMPLETE;

/* Use alternates if necessary */
if (obj_req->http_code == 404) {
if (obj_req->http_code == 404 ||
obj_req->curl_result == CURLE_FILE_COULDNT_READ_FILE) {
fetch_alternates(alt->base);
if (obj_req->repo->next != NULL) {
obj_req->repo =
Expand Down Expand Up @@ -475,7 +476,8 @@ static void process_alternates_response(void *callback_data)
}
}
} else if (slot->curl_result != CURLE_OK) {
if (slot->http_code != 404) {
if (slot->http_code != 404 &&
slot->curl_result != CURLE_FILE_COULDNT_READ_FILE) {
got_alternates = -1;
return;
}
Expand Down Expand Up @@ -637,7 +639,8 @@ static int fetch_indices(struct alt_base *repo)
if (start_active_slot(slot)) {
run_active_slot(slot);
if (slot->curl_result != CURLE_OK) {
if (slot->http_code == 404) {
if (slot->http_code == 404 ||
slot->curl_result == CURLE_FILE_COULDNT_READ_FILE) {
repo->got_indices = 1;
free(buffer.buffer);
return 0;
Expand Down Expand Up @@ -802,7 +805,8 @@ static int fetch_object(struct alt_base *repo, unsigned char *sha1)
ret = error("Request for %s aborted", hex);
} else if (obj_req->curl_result != CURLE_OK &&
obj_req->http_code != 416) {
if (obj_req->http_code == 404)
if (obj_req->http_code == 404 ||
obj_req->curl_result == CURLE_FILE_COULDNT_READ_FILE)
ret = -1; /* Be silent, it is probably in a pack. */
else
ret = error("%s (curl_result = %d, http_code = %ld, sha1 = %s)",
Expand Down

0 comments on commit a14c225

Please sign in to comment.