forked from lix-project/lix
DownloadRequest -> DataTransferRequest
This commit is contained in:
parent
5449ff7d8a
commit
65ef57e0cb
|
@ -36,7 +36,7 @@ void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData)
|
|||
|
||||
/* No need to do TLS verification, because we check the hash of
|
||||
the result anyway. */
|
||||
DownloadRequest request(url);
|
||||
DataTransferRequest request(url);
|
||||
request.verifyTLS = false;
|
||||
request.decompress = false;
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ struct CurlDownloader : public Downloader
|
|||
struct DownloadItem : public std::enable_shared_from_this<DownloadItem>
|
||||
{
|
||||
CurlDownloader & downloader;
|
||||
DownloadRequest request;
|
||||
DataTransferRequest request;
|
||||
DownloadResult result;
|
||||
Activity act;
|
||||
bool done = false; // whether either the success or failure function has been called
|
||||
|
@ -73,7 +73,7 @@ struct CurlDownloader : public Downloader
|
|||
curl_off_t writtenToSink = 0;
|
||||
|
||||
DownloadItem(CurlDownloader & downloader,
|
||||
const DownloadRequest & request,
|
||||
const DataTransferRequest & request,
|
||||
Callback<DownloadResult> && callback)
|
||||
: downloader(downloader)
|
||||
, request(request)
|
||||
|
@ -641,7 +641,7 @@ struct CurlDownloader : public Downloader
|
|||
}
|
||||
#endif
|
||||
|
||||
void enqueueDownload(const DownloadRequest & request,
|
||||
void enqueueDownload(const DataTransferRequest & request,
|
||||
Callback<DownloadResult> callback) override
|
||||
{
|
||||
/* Ugly hack to support s3:// URIs. */
|
||||
|
@ -687,7 +687,7 @@ ref<Downloader> makeDownloader()
|
|||
return make_ref<CurlDownloader>();
|
||||
}
|
||||
|
||||
std::future<DownloadResult> Downloader::enqueueDownload(const DownloadRequest & request)
|
||||
std::future<DownloadResult> Downloader::enqueueDownload(const DataTransferRequest & request)
|
||||
{
|
||||
auto promise = std::make_shared<std::promise<DownloadResult>>();
|
||||
enqueueDownload(request,
|
||||
|
@ -701,12 +701,12 @@ std::future<DownloadResult> Downloader::enqueueDownload(const DownloadRequest &
|
|||
return promise->get_future();
|
||||
}
|
||||
|
||||
DownloadResult Downloader::download(const DownloadRequest & request)
|
||||
DownloadResult Downloader::download(const DataTransferRequest & request)
|
||||
{
|
||||
return enqueueDownload(request).get();
|
||||
}
|
||||
|
||||
void Downloader::download(DownloadRequest && request, Sink & sink)
|
||||
void Downloader::download(DataTransferRequest && request, Sink & sink)
|
||||
{
|
||||
/* Note: we can't call 'sink' via request.dataCallback, because
|
||||
that would cause the sink to execute on the downloader
|
||||
|
@ -801,7 +801,6 @@ void Downloader::download(DownloadRequest && request, Sink & sink)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
bool isUri(const string & s)
|
||||
{
|
||||
if (s.compare(0, 8, "channel:") == 0) return true;
|
||||
|
|
|
@ -33,7 +33,7 @@ struct DownloadSettings : Config
|
|||
|
||||
extern DownloadSettings downloadSettings;
|
||||
|
||||
struct DownloadRequest
|
||||
struct DataTransferRequest
|
||||
{
|
||||
std::string uri;
|
||||
std::string expectedETag;
|
||||
|
@ -47,7 +47,7 @@ struct DownloadRequest
|
|||
std::string mimeType;
|
||||
std::function<void(char *, size_t)> dataCallback;
|
||||
|
||||
DownloadRequest(const std::string & uri)
|
||||
DataTransferRequest(const std::string & uri)
|
||||
: uri(uri), parentAct(getCurActivity()) { }
|
||||
|
||||
std::string verb()
|
||||
|
@ -74,17 +74,17 @@ struct Downloader
|
|||
/* Enqueue a download request, returning a future to the result of
|
||||
the download. The future may throw a DownloadError
|
||||
exception. */
|
||||
virtual void enqueueDownload(const DownloadRequest & request,
|
||||
virtual void enqueueDownload(const DataTransferRequest & request,
|
||||
Callback<DownloadResult> callback) = 0;
|
||||
|
||||
std::future<DownloadResult> enqueueDownload(const DownloadRequest & request);
|
||||
std::future<DownloadResult> enqueueDownload(const DataTransferRequest & request);
|
||||
|
||||
/* Synchronously download a file. */
|
||||
DownloadResult download(const DownloadRequest & request);
|
||||
DownloadResult download(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(DownloadRequest && request, Sink & sink);
|
||||
void download(DataTransferRequest && request, Sink & sink);
|
||||
|
||||
enum Error { NotFound, Forbidden, Misc, Transient, Interrupted };
|
||||
};
|
||||
|
|
|
@ -85,7 +85,7 @@ protected:
|
|||
checkEnabled();
|
||||
|
||||
try {
|
||||
DownloadRequest request(cacheUri + "/" + path);
|
||||
DataTransferRequest request(cacheUri + "/" + path);
|
||||
request.head = true;
|
||||
getDownloader()->download(request);
|
||||
return true;
|
||||
|
@ -103,7 +103,7 @@ protected:
|
|||
const std::string & data,
|
||||
const std::string & mimeType) override
|
||||
{
|
||||
auto req = DownloadRequest(cacheUri + "/" + path);
|
||||
auto req = DataTransferRequest(cacheUri + "/" + path);
|
||||
req.data = std::make_shared<string>(data); // FIXME: inefficient
|
||||
req.mimeType = mimeType;
|
||||
try {
|
||||
|
@ -113,9 +113,9 @@ protected:
|
|||
}
|
||||
}
|
||||
|
||||
DownloadRequest makeRequest(const std::string & path)
|
||||
DataTransferRequest makeRequest(const std::string & path)
|
||||
{
|
||||
DownloadRequest request(cacheUri + "/" + path);
|
||||
DataTransferRequest request(cacheUri + "/" + path);
|
||||
return request;
|
||||
}
|
||||
|
||||
|
|
|
@ -180,7 +180,7 @@ static int _main(int argc, char * * argv)
|
|||
|
||||
FdSink sink(fd.get());
|
||||
|
||||
DownloadRequest req(actualUri);
|
||||
DataTransferRequest req(actualUri);
|
||||
req.decompress = false;
|
||||
getDownloader()->download(std::move(req), sink);
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand
|
|||
Activity act(*logger, lvlInfo, actUnknown, "querying latest Nix version");
|
||||
|
||||
// FIXME: use nixos.org?
|
||||
auto req = DownloadRequest(storePathsUrl);
|
||||
auto req = DataTransferRequest(storePathsUrl);
|
||||
auto res = getDownloader()->download(req);
|
||||
|
||||
auto state = std::make_unique<EvalState>(Strings(), store);
|
||||
|
|
Loading…
Reference in a new issue