libstore: de-future-ize FileTransfer::enqueueUpload
it's only used once, and synchronously at that.
Change-Id: Ife9db15dd97bc0de8de59a25d27f3f7afeb8791b
This commit is contained in:
parent
6f18e1ebde
commit
5cd7055044
|
@ -663,10 +663,9 @@ struct curlFileTransfer : public FileTransfer
|
||||||
return enqueueFileTransfer(uri, headers, std::nullopt, false);
|
return enqueueFileTransfer(uri, headers, std::nullopt, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::future<FileTransferResult>
|
void upload(const std::string & uri, std::string data, const Headers & headers) override
|
||||||
enqueueUpload(const std::string & uri, std::string data, const Headers & headers) override
|
|
||||||
{
|
{
|
||||||
return enqueueFileTransfer(uri, headers, std::move(data), false);
|
enqueueFileTransfer(uri, headers, std::move(data), false).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::future<FileTransferResult> enqueueFileTransfer(
|
std::future<FileTransferResult> enqueueFileTransfer(
|
||||||
|
|
|
@ -80,8 +80,8 @@ struct FileTransfer
|
||||||
/**
|
/**
|
||||||
* Upload some data. May throw a FileTransferError exception.
|
* Upload some data. May throw a FileTransferError exception.
|
||||||
*/
|
*/
|
||||||
virtual std::future<FileTransferResult>
|
virtual void
|
||||||
enqueueUpload(const std::string & uri, std::string data, const Headers & headers = {}) = 0;
|
upload(const std::string & uri, std::string data, const Headers & headers = {}) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the given URI exists. For historical reasons this function
|
* Checks whether the given URI exists. For historical reasons this function
|
||||||
|
|
|
@ -127,9 +127,7 @@ protected:
|
||||||
{
|
{
|
||||||
auto data = StreamToSourceAdapter(istream).drain();
|
auto data = StreamToSourceAdapter(istream).drain();
|
||||||
try {
|
try {
|
||||||
getFileTransfer()
|
getFileTransfer()->upload(makeURI(path), std::move(data), {{"Content-Type", mimeType}});
|
||||||
->enqueueUpload(makeURI(path), std::move(data), {{"Content-Type", mimeType}})
|
|
||||||
.get();
|
|
||||||
} catch (FileTransferError & e) {
|
} catch (FileTransferError & e) {
|
||||||
throw UploadToHTTP(
|
throw UploadToHTTP(
|
||||||
"while uploading to HTTP binary cache at '%s': %s", cacheUri, e.msg()
|
"while uploading to HTTP binary cache at '%s': %s", cacheUri, e.msg()
|
||||||
|
|
Loading…
Reference in a new issue