diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2010-04-17 13:07:38 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-04-17 13:55:46 -0700 |
commit | 0da8b2e7c80a6dd9743e5233cdc5acd836c9a8d3 (patch) | |
tree | 1c8f8548342df22ca2728428f0dcf7f0f0890a22 /http.c | |
parent | 3065274c58a4f4d0c6eef7e29a1484cf2c288131 (diff) | |
download | git-0da8b2e7c80a6dd9743e5233cdc5acd836c9a8d3.tar.gz |
http.c: Don't store destination name in request structures
The destination name within the object store is easily computed
on demand, reusing a static buffer held by sha1_file.c. We don't
need to copy the entire path into the request structure for safe
keeping, when it can be easily reformatted after the download has
been completed.
This reduces the size of the per-request structure, and removes
yet another PATH_MAX based limit.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'http.c')
-rw-r--r-- | http.c | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -1014,7 +1014,7 @@ int finish_http_pack_request(struct http_pack_request *preq) lst = &((*lst)->next); *lst = (*lst)->next; - ret = move_temp_to_file(preq->tmpfile, preq->filename); + ret = move_temp_to_file(preq->tmpfile, sha1_pack_name(p->sha1)); if (ret) return ret; if (verify_pack(p)) @@ -1043,7 +1043,6 @@ struct http_pack_request *new_http_pack_request( preq->url = strbuf_detach(&buf, NULL); filename = sha1_pack_name(target->sha1); - snprintf(preq->filename, sizeof(preq->filename), "%s", filename); snprintf(preq->tmpfile, sizeof(preq->tmpfile), "%s.temp", filename); preq->packfile = fopen(preq->tmpfile, "a"); if (!preq->packfile) { @@ -1133,7 +1132,6 @@ struct http_object_request *new_http_object_request(const char *base_url, freq->localfile = -1; filename = sha1_file_name(sha1); - snprintf(freq->filename, sizeof(freq->filename), "%s", filename); snprintf(freq->tmpfile, sizeof(freq->tmpfile), "%s.temp", filename); @@ -1162,8 +1160,8 @@ struct http_object_request *new_http_object_request(const char *base_url, } if (freq->localfile < 0) { - error("Couldn't create temporary file %s for %s: %s", - freq->tmpfile, freq->filename, strerror(errno)); + error("Couldn't create temporary file %s: %s", + freq->tmpfile, strerror(errno)); goto abort; } @@ -1210,8 +1208,8 @@ struct http_object_request *new_http_object_request(const char *base_url, prev_posn = 0; lseek(freq->localfile, 0, SEEK_SET); if (ftruncate(freq->localfile, 0) < 0) { - error("Couldn't truncate temporary file %s for %s: %s", - freq->tmpfile, freq->filename, strerror(errno)); + error("Couldn't truncate temporary file %s: %s", + freq->tmpfile, strerror(errno)); goto abort; } } @@ -1287,7 +1285,7 @@ int finish_http_object_request(struct http_object_request *freq) return -1; } freq->rename = - move_temp_to_file(freq->tmpfile, freq->filename); + move_temp_to_file(freq->tmpfile, sha1_file_name(freq->sha1)); return freq->rename; } |