mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-26 15:56:18 +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();
|
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)
|
void DataTransfer::download(DataTransferRequest && request, Sink & sink)
|
||||||
{
|
{
|
||||||
/* Note: we can't call 'sink' via request.dataCallback, because
|
/* Note: we can't call 'sink' via request.dataCallback, because
|
||||||
|
|
|
@ -82,6 +82,9 @@ struct DataTransfer
|
||||||
/* Synchronously download a file. */
|
/* Synchronously download a file. */
|
||||||
DataTransferResult download(const DataTransferRequest & request);
|
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
|
/* Download a file, writing its data to a sink. The sink will be
|
||||||
invoked on the thread of the caller. */
|
invoked on the thread of the caller. */
|
||||||
void download(DataTransferRequest && request, Sink & sink);
|
void download(DataTransferRequest && request, Sink & sink);
|
||||||
|
|
|
@ -107,7 +107,7 @@ protected:
|
||||||
req.data = std::make_shared<string>(data); // FIXME: inefficient
|
req.data = std::make_shared<string>(data); // FIXME: inefficient
|
||||||
req.mimeType = mimeType;
|
req.mimeType = mimeType;
|
||||||
try {
|
try {
|
||||||
getDataTransfer()->download(req);
|
getDataTransfer()->upload(req);
|
||||||
} catch (DataTransferError & e) {
|
} catch (DataTransferError & e) {
|
||||||
throw UploadToHTTP("while uploading to HTTP binary cache at '%s': %s", cacheUri, e.msg());
|
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