mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 14:06:16 +02:00
Add upload method
This commit is contained in:
parent
a0c5931208
commit
7848372b0f
3 changed files with 10 additions and 2 deletions
|
@ -706,6 +706,12 @@ DataTransferResult DataTransfer::download(const DataTransferRequest & request)
|
|||
return enqueueDataTransfer(request).get();
|
||||
}
|
||||
|
||||
DataTransferResult DataTransfer::upload(const DataTransferRequest & request)
|
||||
{
|
||||
/* Note: this method is the same as download, but helps in readability */
|
||||
return enqueueDataTransfer(request).get();
|
||||
}
|
||||
|
||||
void DataTransfer::download(DataTransferRequest && request, Sink & sink)
|
||||
{
|
||||
/* Note: we can't call 'sink' via request.dataCallback, because
|
||||
|
|
|
@ -82,6 +82,9 @@ struct DataTransfer
|
|||
/* Synchronously download a file. */
|
||||
DataTransferResult download(const DataTransferRequest & request);
|
||||
|
||||
/* Synchronously upload a file. */
|
||||
DataTransferResult upload(const DataTransferRequest & request);
|
||||
|
||||
/* Download a file, writing its data to a sink. The sink will be
|
||||
invoked on the thread of the caller. */
|
||||
void download(DataTransferRequest && request, Sink & sink);
|
||||
|
|
|
@ -107,7 +107,7 @@ protected:
|
|||
req.data = std::make_shared<string>(data); // FIXME: inefficient
|
||||
req.mimeType = mimeType;
|
||||
try {
|
||||
getDataTransfer()->download(req);
|
||||
getDataTransfer()->upload(req);
|
||||
} catch (DataTransferError & e) {
|
||||
throw UploadToHTTP("while uploading to HTTP binary cache at '%s': %s", cacheUri, e.msg());
|
||||
}
|
||||
|
@ -174,4 +174,3 @@ static RegisterStoreImplementation regStore([](
|
|||
});
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue