2268
2269
int finish_http_pack_request(struct http_pack_request *preq)
2270
{
2271
- struct packed_git **lst;
2272
- struct packed_git *p = preq->target;
2271
struct child_process ip = CHILD_PROCESS_INIT;
2272
int tmpfile_fd;
2273
int ret = 0;
2274
2277
- close_pack_index(p);
2278
-
2275
fclose(preq->packfile);
2276
preq->packfile = NULL;
2277
2282
- lst = preq->lst;
2283
- while (*lst != p)
2284
- lst = &((*lst)->next);
2285
- *lst = (*lst)->next;
2286
-
2278
tmpfile_fd = xopen(preq->tmpfile.buf, O_RDONLY);
2279
2280
argv_array_push(&ip.args, "index-pack");
2288
goto cleanup;
2289
}
2290
2300
- install_packed_git(the_repository, p);
2291
cleanup:
2292
close(tmpfile_fd);
2293
unlink(preq->tmpfile.buf);
2294
return ret;
2295
}
2296
2297
+void http_install_packfile(struct packed_git *p,
2298
+ struct packed_git **list_to_remove_from)
2299
+{
2300
+ struct packed_git **lst = list_to_remove_from;
2301
+
2302
+ while (*lst != p)
2303
+ lst = &((*lst)->next);
2304
+ *lst = (*lst)->next;
2305
+
2306
+ install_packed_git(the_repository, p);
2307
+}
2308
+
2309
struct http_pack_request *new_http_pack_request(
2308
- struct packed_git *target, const char *base_url)
2310
+ const unsigned char *packed_git_hash, const char *base_url)
2311
{
2312
off_t prev_posn = 0;
2313
struct strbuf buf = STRBUF_INIT;
2315
2316
preq = xcalloc(1, sizeof(*preq));
2317
strbuf_init(&preq->tmpfile, 0);
2316
- preq->target = target;
2318
2319
end_url_with_slash(&buf, base_url);
2320
strbuf_addf(&buf, "objects/pack/pack-%s.pack",
2320
- hash_to_hex(target->hash));
2321
+ hash_to_hex(packed_git_hash));
2322
preq->url = strbuf_detach(&buf, NULL);
2323
2323
- strbuf_addf(&preq->tmpfile, "%s.temp", sha1_pack_name(target->hash));
2324
+ strbuf_addf(&preq->tmpfile, "%s.temp", sha1_pack_name(packed_git_hash));
2325
preq->packfile = fopen(preq->tmpfile.buf, "a");
2326
if (!preq->packfile) {
2327
error("Unable to open local file %s for pack",
2345
if (http_is_verbose)
2346
fprintf(stderr,
2347
"Resuming fetch of pack %s at byte %"PRIuMAX"\n",
2347
- hash_to_hex(target->hash),
2348
+ hash_to_hex(packed_git_hash),
2349
(uintmax_t)prev_posn);
2350
http_opt_request_remainder(preq->slot->curl, prev_posn);
2351
}