// Follow any redirects
curl_easy_setopt(transfer->handle, CURLOPT_FOLLOWLOCATION, 1);
- // Open a temporary file to write the output to
- transfer->f = pakfire_mktemp(transfer->tempfile);
- if (!transfer->f) {
- ERROR(downloader->pakfire, "Could not create temporary file for download %s: %s\n",
- transfer->tempfile, strerror(errno));
- goto ERROR;
- }
-
- curl_easy_setopt(transfer->handle, CURLOPT_WRITEDATA, transfer->f);
-
// Success
return transfer;
return 1;
}
+ // Open a temporary file to write the output to
+ if (!transfer->f) {
+ transfer->f = pakfire_mktemp(transfer->tempfile);
+ if (!transfer->f) {
+ ERROR(downloader->pakfire, "Could not create temporary file for download %s: %s\n",
+ transfer->tempfile, strerror(errno));
+ return 1;
+ }
+
+ curl_easy_setopt(transfer->handle, CURLOPT_WRITEDATA, transfer->f);
+ }
+
return 0;
}