1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 19:01:16 +02:00

Refactor downloadCached() interface

This commit is contained in:
Eelco Dolstra 2019-05-22 23:36:29 +02:00
parent 66f1d7ee95
commit df3f5a78d5
7 changed files with 73 additions and 54 deletions

View file

@ -136,9 +136,11 @@ std::shared_ptr<FlakeRegistry> EvalState::getGlobalFlakeRegistry()
std::call_once(_globalFlakeRegistryInit, [&]() {
auto path = evalSettings.flakeRegistry;
if (!hasPrefix(path, "/"))
path = getDownloader()->downloadCached(store,
evalSettings.flakeRegistry, false, "registry").path;
if (!hasPrefix(path, "/")) {
CachedDownloadRequest request(evalSettings.flakeRegistry);
request.name = "flake-registry.json";
path = getDownloader()->downloadCached(store, request).path;
}
_globalFlakeRegistry = readRegistry(path);
});
@ -244,8 +246,11 @@ static SourceInfo fetchFlake(EvalState & state, const FlakeRef & flakeRef, bool
if (accessToken != "")
url += "?access_token=" + accessToken;
auto result = getDownloader()->downloadCached(state.store, url, true, "source",
Hash(), nullptr, resolvedRef.rev ? 1000000000 : settings.tarballTtl);
CachedDownloadRequest request(url);
request.unpack = true;
request.name = "source";
request.ttl = resolvedRef.rev ? 1000000000 : settings.tarballTtl;
auto result = getDownloader()->downloadCached(state.store, request);
if (!result.etag)
throw Error("did not receive an ETag header from '%s'", url);