| 2968 | } |
| 2969 | |
| 2970 | int finish_http_object_request(struct http_object_request *freq) |
| 2971 | { |
| 2972 | struct odb_source_files *files = odb_source_files_downcast(the_repository->objects->sources); |
| 2973 | struct stat st; |
| 2974 | struct strbuf filename = STRBUF_INIT; |
| 2975 | |
| 2976 | close(freq->localfile); |
| 2977 | freq->localfile = -1; |
| 2978 | |
| 2979 | process_http_object_request(freq); |
| 2980 | |
| 2981 | if (freq->http_code == 416) { |
| 2982 | warning("requested range invalid; we may already have all the data."); |
| 2983 | } else if (freq->curl_result != CURLE_OK) { |
| 2984 | if (stat(freq->tmpfile.buf, &st) == 0) |
| 2985 | if (st.st_size == 0) |
| 2986 | unlink_or_warn(freq->tmpfile.buf); |
| 2987 | return -1; |
| 2988 | } |
| 2989 | |
| 2990 | git_hash_final_oid(&freq->real_oid, &freq->c); |
| 2991 | if (freq->zret != Z_STREAM_END) { |
| 2992 | unlink_or_warn(freq->tmpfile.buf); |
| 2993 | return -1; |
| 2994 | } |
| 2995 | if (!oideq(&freq->oid, &freq->real_oid)) { |
| 2996 | unlink_or_warn(freq->tmpfile.buf); |
| 2997 | return -1; |
| 2998 | } |
| 2999 | odb_loose_path(files->loose, &filename, &freq->oid); |
| 3000 | freq->rename = finalize_object_file(the_repository, freq->tmpfile.buf, filename.buf); |
| 3001 | strbuf_release(&filename); |
| 3002 | |
| 3003 | return freq->rename; |
| 3004 | } |
| 3005 | |
| 3006 | void abort_http_object_request(struct http_object_request **freq_p) |
| 3007 | { |
no test coverage detected