Skip to content

Commit a14c225

Browse files
Nick HengeveldJunio C Hamano
authored andcommitted
Fix for http-fetch from file:// URLs
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>
1 parent e99fcf9 commit a14c225

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

http-fetch.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ static void process_object_response(void *callback_data)
267267
obj_req->state = COMPLETE;
268268

269269
/* Use alternates if necessary */
270-
if (obj_req->http_code == 404) {
270+
if (obj_req->http_code == 404 ||
271+
obj_req->curl_result == CURLE_FILE_COULDNT_READ_FILE) {
271272
fetch_alternates(alt->base);
272273
if (obj_req->repo->next != NULL) {
273274
obj_req->repo =
@@ -475,7 +476,8 @@ static void process_alternates_response(void *callback_data)
475476
}
476477
}
477478
} else if (slot->curl_result != CURLE_OK) {
478-
if (slot->http_code != 404) {
479+
if (slot->http_code != 404 &&
480+
slot->curl_result != CURLE_FILE_COULDNT_READ_FILE) {
479481
got_alternates = -1;
480482
return;
481483
}
@@ -637,7 +639,8 @@ static int fetch_indices(struct alt_base *repo)
637639
if (start_active_slot(slot)) {
638640
run_active_slot(slot);
639641
if (slot->curl_result != CURLE_OK) {
640-
if (slot->http_code == 404) {
642+
if (slot->http_code == 404 ||
643+
slot->curl_result == CURLE_FILE_COULDNT_READ_FILE) {
641644
repo->got_indices = 1;
642645
free(buffer.buffer);
643646
return 0;
@@ -802,7 +805,8 @@ static int fetch_object(struct alt_base *repo, unsigned char *sha1)
802805
ret = error("Request for %s aborted", hex);
803806
} else if (obj_req->curl_result != CURLE_OK &&
804807
obj_req->http_code != 416) {
805-
if (obj_req->http_code == 404)
808+
if (obj_req->http_code == 404 ||
809+
obj_req->curl_result == CURLE_FILE_COULDNT_READ_FILE)
806810
ret = -1; /* Be silent, it is probably in a pack. */
807811
else
808812
ret = error("%s (curl_result = %d, http_code = %ld, sha1 = %s)",

0 commit comments

Comments
 (0)