// Copy path
pakfire_string_set(transfer->path, path);
+ // Open the desination file if we do not want a temporary file
+ if (flags & PAKFIRE_TRANSFER_NOTEMP) {
+ transfer->f = fopen(path, "w+");
+ if (!transfer->f)
+ goto ERROR;
+ }
+
// Copy baseurl
if (baseurl)
pakfire_string_set(transfer->baseurl, baseurl);
static int pakfire_transfer_save(struct pakfire_downloader* downloader,
struct pakfire_transfer* transfer) {
struct utimbuf times;
+ int r;
DEBUG(downloader->pakfire,
"Download successful. Storing result in %s\n", transfer->path);
- // Remove destination (if it exists)
- unlink(transfer->path);
+ if (!(transfer->flags & PAKFIRE_TRANSFER_NOTEMP)) {
+ // Remove destination (if it exists)
+ unlink(transfer->path);
- // Move the temporary file to its destination
- int r = link(transfer->tempfile, transfer->path);
- if (r) {
- ERROR(downloader->pakfire, "Could not link destination file %s: %s\n",
- transfer->path, strerror(errno));
- return r;
+ // Move the temporary file to its destination
+ r = link(transfer->tempfile, transfer->path);
+ if (r) {
+ ERROR(downloader->pakfire, "Could not link destination file %s: %s\n",
+ transfer->path, strerror(errno));
+ return r;
+ }
}
// Filetime
transfer->tempfile, strerror(errno));
return 1;
}
-
- curl_easy_setopt(transfer->handle, CURLOPT_WRITEDATA, transfer->f);
}
+ // Write all data to the allocated file descriptor
+ curl_easy_setopt(transfer->handle, CURLOPT_WRITEDATA, transfer->f);
+
return 0;
}