Make http-push smarter about creating remote dirs
Remember object directories known to exist in the remote repo and don't bother trying to create them. Signed-off-by: Nick Hengeveld <nickh@reactrix.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
committed by
Junio C Hamano
parent
5e0306adfa
commit
0dd276b871
@@ -47,6 +47,7 @@ static int active_requests = 0;
|
|||||||
static int data_received;
|
static int data_received;
|
||||||
static int pushing = 0;
|
static int pushing = 0;
|
||||||
static int aborted = 0;
|
static int aborted = 0;
|
||||||
|
static char remote_dir_exists[256];
|
||||||
|
|
||||||
#ifdef USE_CURL_MULTI
|
#ifdef USE_CURL_MULTI
|
||||||
static int max_requests = -1;
|
static int max_requests = -1;
|
||||||
@@ -650,6 +651,7 @@ static void finish_request(struct transfer_request *request)
|
|||||||
if (request->http_code == 404) {
|
if (request->http_code == 404) {
|
||||||
request->state = NEED_PUSH;
|
request->state = NEED_PUSH;
|
||||||
} else if (request->curl_result == CURLE_OK) {
|
} else if (request->curl_result == CURLE_OK) {
|
||||||
|
remote_dir_exists[request->sha1[0]] = 1;
|
||||||
request->state = COMPLETE;
|
request->state = COMPLETE;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "HEAD %s failed, aborting (%d/%ld)\n",
|
fprintf(stderr, "HEAD %s failed, aborting (%d/%ld)\n",
|
||||||
@@ -661,6 +663,7 @@ static void finish_request(struct transfer_request *request)
|
|||||||
} else if (request->state == RUN_MKCOL) {
|
} else if (request->state == RUN_MKCOL) {
|
||||||
if (request->curl_result == CURLE_OK ||
|
if (request->curl_result == CURLE_OK ||
|
||||||
request->http_code == 405) {
|
request->http_code == 405) {
|
||||||
|
remote_dir_exists[request->sha1[0]] = 1;
|
||||||
start_put(request);
|
start_put(request);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "MKCOL %s failed, aborting (%d/%ld)\n",
|
fprintf(stderr, "MKCOL %s failed, aborting (%d/%ld)\n",
|
||||||
@@ -767,6 +770,9 @@ void process_request_queue(void)
|
|||||||
start_check(request);
|
start_check(request);
|
||||||
curl_multi_perform(curlm, &num_transfers);
|
curl_multi_perform(curlm, &num_transfers);
|
||||||
} else if (pushing && request->state == NEED_PUSH) {
|
} else if (pushing && request->state == NEED_PUSH) {
|
||||||
|
if (remote_dir_exists[request->sha1[0]])
|
||||||
|
start_put(request);
|
||||||
|
else
|
||||||
start_mkcol(request);
|
start_mkcol(request);
|
||||||
curl_multi_perform(curlm, &num_transfers);
|
curl_multi_perform(curlm, &num_transfers);
|
||||||
}
|
}
|
||||||
@@ -1599,6 +1605,8 @@ int main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset(remote_dir_exists, 0, 256);
|
||||||
|
|
||||||
curl_global_init(CURL_GLOBAL_ALL);
|
curl_global_init(CURL_GLOBAL_ALL);
|
||||||
|
|
||||||
#ifdef USE_CURL_MULTI
|
#ifdef USE_CURL_MULTI
|
||||||
|
|||||||
Reference in New Issue
Block a user