mirror of
https://github.com/NixOS/nix
synced 2025-07-06 21:41:48 +02:00
Refactor downloadCached() interface
(cherry picked from commit df3f5a78d5
)
This commit is contained in:
parent
7b9c68766d
commit
f8b30338ac
6 changed files with 63 additions and 49 deletions
|
@ -86,10 +86,12 @@ static void update(const StringSet & channelNames)
|
|||
// We want to download the url to a file to see if it's a tarball while also checking if we
|
||||
// got redirected in the process, so that we can grab the various parts of a nix channel
|
||||
// definition from a consistent location if the redirect changes mid-download.
|
||||
std::string effectiveUrl;
|
||||
CachedDownloadRequest request(url);
|
||||
request.ttl = 0;
|
||||
auto dl = getDownloader();
|
||||
auto filename = dl->downloadCached(store, url, false, "", Hash(), &effectiveUrl, 0).path;
|
||||
url = chomp(std::move(effectiveUrl));
|
||||
auto result = dl->downloadCached(store, request);
|
||||
auto filename = result.path;
|
||||
url = chomp(result.effectiveUri);
|
||||
|
||||
// If the URL contains a version number, append it to the name
|
||||
// attribute (so that "nix-env -q" on the channels profile
|
||||
|
@ -121,12 +123,10 @@ static void update(const StringSet & channelNames)
|
|||
}
|
||||
|
||||
// Download the channel tarball.
|
||||
auto fullURL = url + "/nixexprs.tar.xz";
|
||||
try {
|
||||
filename = dl->downloadCached(store, fullURL, false).path;
|
||||
filename = dl->downloadCached(store, CachedDownloadRequest(url + "/nixexprs.tar.xz")).path;
|
||||
} catch (DownloadError & e) {
|
||||
fullURL = url + "/nixexprs.tar.bz2";
|
||||
filename = dl->downloadCached(store, fullURL, false).path;
|
||||
filename = dl->downloadCached(store, CachedDownloadRequest(url + "/nixexprs.tar.bz2")).path;
|
||||
}
|
||||
chomp(filename);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue