libstore: remove Filetransfer::transfer
just use enqueueFileTransfer().get() insteaad.
Change-Id: I67a43c9d3d5f68ac3f9e8ba7973c243dd78b86a3
This commit is contained in:
parent
98b55c3a1d
commit
2d49efaa2e
|
@ -46,7 +46,7 @@ DownloadFileResult downloadFile(
|
|||
request.expectedETag = getStrAttr(cached->infoAttrs, "etag");
|
||||
FileTransferResult res;
|
||||
try {
|
||||
res = getFileTransfer()->transfer(request);
|
||||
res = getFileTransfer()->enqueueFileTransfer(request).get();
|
||||
} catch (FileTransferError & e) {
|
||||
if (cached) {
|
||||
warn("%s; using cached version", e.msg());
|
||||
|
|
|
@ -868,11 +868,6 @@ ref<FileTransfer> makeFileTransfer()
|
|||
return makeCurlFileTransfer();
|
||||
}
|
||||
|
||||
FileTransferResult FileTransfer::transfer(const FileTransferRequest & request)
|
||||
{
|
||||
return enqueueFileTransfer(request).get();
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
FileTransferError::FileTransferError(FileTransfer::Error error, std::optional<std::string> response, const Args & ... args)
|
||||
: Error(args...), error(error), response(response)
|
||||
|
|
|
@ -94,11 +94,6 @@ struct FileTransfer
|
|||
*/
|
||||
virtual std::future<FileTransferResult> enqueueFileTransfer(const FileTransferRequest & request) = 0;
|
||||
|
||||
/**
|
||||
* Synchronously transfer a file.
|
||||
*/
|
||||
FileTransferResult transfer(const FileTransferRequest & request);
|
||||
|
||||
/**
|
||||
* Download a file, returning its contents through a source. Will not return
|
||||
* before the transfer has fully started, ensuring that any errors thrown by
|
||||
|
|
|
@ -116,7 +116,7 @@ protected:
|
|||
try {
|
||||
FileTransferRequest request{makeURI(path)};
|
||||
request.head = true;
|
||||
getFileTransfer()->transfer(request);
|
||||
getFileTransfer()->enqueueFileTransfer(request).get();
|
||||
return true;
|
||||
} catch (FileTransferError & e) {
|
||||
/* S3 buckets return 403 if a file doesn't exist and the
|
||||
|
@ -136,7 +136,7 @@ protected:
|
|||
req.data = StreamToSourceAdapter(istream).drain();
|
||||
req.headers = {{"Content-Type", mimeType}};
|
||||
try {
|
||||
getFileTransfer()->transfer(req);
|
||||
getFileTransfer()->enqueueFileTransfer(req).get();
|
||||
} catch (FileTransferError & e) {
|
||||
throw UploadToHTTP("while uploading to HTTP binary cache at '%s': %s", cacheUri, e.msg());
|
||||
}
|
||||
|
|
|
@ -286,7 +286,7 @@ struct CmdUpgradeNix : MixDryRun, EvalCommand
|
|||
|
||||
// FIXME: use nixos.org?
|
||||
auto req = FileTransferRequest(storePathsUrl);
|
||||
auto res = getFileTransfer()->transfer(req);
|
||||
auto res = getFileTransfer()->enqueueFileTransfer(req).get();
|
||||
|
||||
auto state = std::make_unique<EvalState>(SearchPath{}, store);
|
||||
auto v = state->allocValue();
|
||||
|
|
|
@ -163,8 +163,9 @@ TEST(FileTransfer, NOT_ON_DARWIN(reportsSetupErrors))
|
|||
auto [port, srv] = serveHTTP("404 not found", "", [] { return ""; });
|
||||
auto ft = makeFileTransfer();
|
||||
ASSERT_THROW(
|
||||
ft->transfer(FileTransferRequest(fmt("http://[::1]:%d/index", port))),
|
||||
FileTransferError);
|
||||
ft->enqueueFileTransfer(FileTransferRequest(fmt("http://[::1]:%d/index", port))).get(),
|
||||
FileTransferError
|
||||
);
|
||||
}
|
||||
|
||||
TEST(FileTransfer, NOT_ON_DARWIN(defersFailures))
|
||||
|
@ -218,7 +219,7 @@ TEST(FileTransfer, usesIntermediateLinkHeaders)
|
|||
auto ft = makeFileTransfer();
|
||||
FileTransferRequest req(fmt("http://[::1]:%d/first", port));
|
||||
req.baseRetryTimeMs = 0;
|
||||
auto result = ft->transfer(req);
|
||||
auto result = ft->enqueueFileTransfer(req).get();
|
||||
ASSERT_EQ(result.immutableUrl, "http://foo");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue