X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=http-fetch.c;h=71a8c60b56914ca579db3da1d2bef6795acc7bf9;hb=d1c5f2a42d7b5c0e3d3862212dea1f09809c4963;hp=778d508243e78bc5c3dce2d71ab6c225c6a3159f;hpb=49a0f240f7be05728f97903efd97ad7898ff6d08;p=git.git diff --git a/http-fetch.c b/http-fetch.c index 778d5082..71a8c60b 100644 --- a/http-fetch.c +++ b/http-fetch.c @@ -1,6 +1,6 @@ #include "cache.h" #include "commit.h" - +#include "pack.h" #include "fetch.h" #include @@ -431,6 +431,8 @@ static int fetch_pack(struct alt_base *repo, unsigned char *sha1) lst = &((*lst)->next); *lst = (*lst)->next; + if (verify_pack(target, 0)) + return -1; install_packed_git(target); return 0; @@ -456,9 +458,13 @@ static int fetch_object(struct alt_base *repo, unsigned char *sha1) snprintf(tmpfile, sizeof(tmpfile), "%s.temp", filename); snprintf(prevfile, sizeof(prevfile), "%s.prev", filename); - unlink(prevfile); - rename(tmpfile, prevfile); - unlink(tmpfile); + + if (unlink(prevfile) && (errno != ENOENT)) + return error("Failed to unlink %s (%s)", + prevfile, strerror(errno)); + if (rename(tmpfile, prevfile) && (errno != ENOENT)) + return error("Failed to rename %s to %s (%s)", + tmpfile, prevfile, strerror(errno)); local = open(tmpfile, O_WRONLY | O_CREAT | O_EXCL, 0666); @@ -523,6 +529,7 @@ static int fetch_object(struct alt_base *repo, unsigned char *sha1) if (prev_posn>0) { prev_posn = 0; lseek(local, SEEK_SET, 0); + ftruncate(local, 0); } } @@ -543,7 +550,6 @@ static int fetch_object(struct alt_base *repo, unsigned char *sha1) curl_result = curl_easy_perform(curl); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, no_range_header); if (curl_result != 0) { - unlink(tmpfile); return error("%s", curl_errorstr); }