static void finish_request(struct transfer_request *request)
{
+ struct stat st;
+
fchmod(request->local, 0444);
close(request->local);
if (request->http_code == 416) {
fprintf(stderr, "Warning: requested range invalid; we may already have all the data.\n");
} else if (request->curl_result != CURLE_OK) {
+ if (stat(request->tmpfile, &st) == 0)
+ if (st.st_size == 0)
+ unlink(request->tmpfile);
return;
}
while (curl_message != NULL) {
if (curl_message->msg == CURLMSG_DONE) {
+ int curl_result = curl_message->data.result;
slot = active_queue_head;
while (slot != NULL &&
slot->curl != curl_message->easy_handle)
active_requests--;
slot->done = 1;
slot->in_use = 0;
- slot->curl_result = curl_message->data.result;
+ slot->curl_result = curl_result;
curl_easy_getinfo(slot->curl,
CURLINFO_HTTP_CODE,
&slot->http_code);
fprintf(stderr, "Received DONE message for unknown request!\n");
}
if (request != NULL) {
- request->curl_result =
- curl_message->data.result;
+ request->curl_result = curl_result;
request->http_code = slot->http_code;
request->slot = NULL;
request->state = COMPLETE;
}
if (request->curl_result != CURLE_OK && request->http_code != 416) {
- ret = error("%s (curl_result = %d, http_code = %ld, sha1 = %s)",
- request->errorstr, request->curl_result,
- request->http_code, hex);
+ if (request->http_code == 404)
+ ret = -1; /* Be silent, it is probably in a pack. */
+ else
+ ret = error("%s (curl_result = %d, http_code = %ld, sha1 = %s)",
+ request->errorstr, request->curl_result,
+ request->http_code, hex);
release_request(request);
return ret;
}