@matheusbsbs / matheus-bagliano / commits / 11f0dafe2b
Fork 0

[PATCH] Don't fetch objects that exist in the local repository

Be sure not to fetch objects that already exist in the local repository. The main process loop no longer performs this check, http-fetch now checks prior to starting a new request queue entry and when fetch_object() is called, and local-fetch now checks when fetch_object() is called. As discussed in this thread: http://marc.theaimsgroup.com/?t=112854890500001 Signed-off-by: Nick Hengeveld <nickh@reactrix.com>

Nick Hengeveld committed Oct 10, 2005 at 23:22 UTC 11f0dafe2be419240c0006c3e9112cbad3568baf
3 files changed +14 -3
fetch.c
+1 -1
@@ -165,7 +165,7 @@ static int loop(void)
165 * the queue because we needed to fetch it first.
166 */
167 if (! (obj->flags & TO_SCAN)) {
168 - if (!has_sha1_file(obj->sha1) && fetch(obj->sha1)) {
168 + if (fetch(obj->sha1)) {
169 report_missing(obj->type
170 ? obj->type
171 : "object", obj->sha1);
http-fetch.c
+9 -1
@@ -489,7 +489,10 @@ void process_request_queue()
489
490 while (active_requests < max_requests && request != NULL) {
491 if (request->state == WAITING) {
492 - start_request(request);
492 + if (has_sha1_file(request->sha1))
493 + release_request(request);
494 + else
495 + start_request(request);
496 curl_multi_perform(curlm, &num_transfers);
497 }
498 request = request->next;
@@ -890,6 +893,11 @@ static int fetch_object(struct alt_base *repo, unsigned char *sha1)
893 if (request == NULL)
894 return error("Couldn't find request for %s in the queue", hex);
895
896 + if (has_sha1_file(request->sha1)) {
897 + release_request(request);
898 + return 0;
899 + }
900 +
901 #ifdef USE_CURL_MULTI
902 int num_transfers;
903 while (request->state == WAITING) {
local-fetch.c
+4 -1
@@ -166,7 +166,10 @@ static int fetch_file(const unsigned char *sha1)
166
167 int fetch(unsigned char *sha1)
168 {
169 - return fetch_file(sha1) && fetch_pack(sha1);
169 + if (has_sha1_file(sha1))
170 + return 0;
171 + else
172 + return fetch_file(sha1) && fetch_pack(sha1);
173 }
174
175 int fetch_ref(char *ref, unsigned char *sha1)