download.hh: Fix conflicts from nix-channel-c++ merge
This commit is contained in:
parent
572aba284a
commit
dfe0938614
3 changed files with 7 additions and 16 deletions
|
@ -249,13 +249,7 @@ ref<Downloader> makeDownloader()
|
||||||
return make_ref<CurlDownloader>();
|
return make_ref<CurlDownloader>();
|
||||||
}
|
}
|
||||||
|
|
||||||
Path Downloader::downloadCached(ref<Store> store, const string & url_, bool unpack, string name, const Hash & expectedHash)
|
Path Downloader::downloadCached(ref<Store> store, const string & url_, bool unpack, string name, const Hash & expectedHash, string * effectiveUrl)
|
||||||
{
|
|
||||||
string ignored;
|
|
||||||
return downloadCached(store, url_, unpack, ignored, expectedHash);
|
|
||||||
}
|
|
||||||
|
|
||||||
Path Downloader::downloadCached(ref<Store> store, const string & url_, bool unpack, string & effectiveUrl, const Hash & expectedHash)
|
|
||||||
{
|
{
|
||||||
auto url = resolveUri(url_);
|
auto url = resolveUri(url_);
|
||||||
|
|
||||||
|
@ -295,7 +289,8 @@ Path Downloader::downloadCached(ref<Store> store, const string & url_, bool unpa
|
||||||
time_t lastChecked;
|
time_t lastChecked;
|
||||||
if (string2Int(ss[2], lastChecked) && lastChecked + ttl >= time(0)) {
|
if (string2Int(ss[2], lastChecked) && lastChecked + ttl >= time(0)) {
|
||||||
skip = true;
|
skip = true;
|
||||||
effectiveUrl = url_;
|
if (effectiveUrl)
|
||||||
|
*effectiveUrl = url_;
|
||||||
} else if (!ss[1].empty()) {
|
} else if (!ss[1].empty()) {
|
||||||
printMsg(lvlDebug, format("verifying previous ETag ‘%1%’") % ss[1]);
|
printMsg(lvlDebug, format("verifying previous ETag ‘%1%’") % ss[1]);
|
||||||
expectedETag = ss[1];
|
expectedETag = ss[1];
|
||||||
|
@ -311,7 +306,8 @@ Path Downloader::downloadCached(ref<Store> store, const string & url_, bool unpa
|
||||||
DownloadOptions options;
|
DownloadOptions options;
|
||||||
options.expectedETag = expectedETag;
|
options.expectedETag = expectedETag;
|
||||||
auto res = download(url, options);
|
auto res = download(url, options);
|
||||||
effectiveUrl = res.effectiveUrl;
|
if (effectiveUrl)
|
||||||
|
*effectiveUrl = res.effectiveUrl;
|
||||||
|
|
||||||
if (!res.cached) {
|
if (!res.cached) {
|
||||||
ValidPathInfo info;
|
ValidPathInfo info;
|
||||||
|
|
|
@ -32,12 +32,7 @@ struct Downloader
|
||||||
virtual DownloadResult download(string url, const DownloadOptions & options) = 0;
|
virtual DownloadResult download(string url, const DownloadOptions & options) = 0;
|
||||||
|
|
||||||
Path downloadCached(ref<Store> store, const string & url, bool unpack, string name = "",
|
Path downloadCached(ref<Store> store, const string & url, bool unpack, string name = "",
|
||||||
const Hash & expectedHash = Hash());
|
const Hash & expectedHash = Hash(), string * effectiveUrl = nullptr);
|
||||||
|
|
||||||
/* Need to overload because can't have an rvalue default value for non-const reference */
|
|
||||||
|
|
||||||
Path downloadCached(ref<Store> store, const string & url, bool unpack,
|
|
||||||
string & effectiveUrl, const Hash & expectedHash = Hash());
|
|
||||||
|
|
||||||
enum Error { NotFound, Forbidden, Misc, Transient };
|
enum Error { NotFound, Forbidden, Misc, Transient };
|
||||||
};
|
};
|
||||||
|
|
|
@ -86,7 +86,7 @@ static void update(const StringSet & channelNames)
|
||||||
// definition from a consistent location if the redirect changes mid-download.
|
// definition from a consistent location if the redirect changes mid-download.
|
||||||
auto effectiveUrl = string{};
|
auto effectiveUrl = string{};
|
||||||
auto dl = makeDownloader();
|
auto dl = makeDownloader();
|
||||||
auto filename = dl->downloadCached(store, url, false, effectiveUrl);
|
auto filename = dl->downloadCached(store, url, false, "", Hash(), &effectiveUrl);
|
||||||
url = chomp(std::move(effectiveUrl));
|
url = chomp(std::move(effectiveUrl));
|
||||||
|
|
||||||
// If the URL contains a version number, append it to the name
|
// If the URL contains a version number, append it to the name
|
||||||
|
|
Loading…
Reference in a new issue