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>
Nick Hengeveld committed
Dec 22, 2005 at 09:09 UTC
a14c225661fa2fc271d9e0fbf262e369dc7254fc
1 file changed
+8
-4
http-fetch.c
+8
-4
@@ -267,7 +267,8 @@ static void process_object_response(void *callback_data)
267
obj_req->state = COMPLETE;
268
269
/* 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) {
272
fetch_alternates(alt->base);
273
if (obj_req->repo->next != NULL) {
274
obj_req->repo =
@@ -475,7 +476,8 @@ static void process_alternates_response(void *callback_data)
476
}
477
}
478
} 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) {
481
got_alternates = -1;
482
return;
483
}
@@ -637,7 +639,8 @@ static int fetch_indices(struct alt_base *repo)
639
if (start_active_slot(slot)) {
640
run_active_slot(slot);
641
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) {
644
repo->got_indices = 1;
645
free(buffer.buffer);
646
return 0;
@@ -802,7 +805,8 @@ static int fetch_object(struct alt_base *repo, unsigned char *sha1)
805
ret = error("Request for %s aborted", hex);
806
} else if (obj_req->curl_result != CURLE_OK &&
807
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)
810
ret = -1; /* Be silent, it is probably in a pack. */
811
else
812
ret = error("%s (curl_result = %d, http_code = %ld, sha1 = %s)",