From dfe09386148901e4d9f2dc84641d2d5544c886f7 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Wed, 31 Aug 2016 09:57:56 -0400 Subject: [PATCH] download.hh: Fix conflicts from nix-channel-c++ merge --- src/libstore/download.cc | 14 +++++--------- src/libstore/download.hh | 7 +------ src/nix-channel/nix-channel.cc | 2 +- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/libstore/download.cc b/src/libstore/download.cc index 5cb2b497a..ed7e124d2 100644 --- a/src/libstore/download.cc +++ b/src/libstore/download.cc @@ -249,13 +249,7 @@ ref makeDownloader() return make_ref(); } -Path Downloader::downloadCached(ref store, const string & url_, bool unpack, string name, const Hash & expectedHash) -{ - string ignored; - return downloadCached(store, url_, unpack, ignored, expectedHash); -} - -Path Downloader::downloadCached(ref store, const string & url_, bool unpack, string & effectiveUrl, const Hash & expectedHash) +Path Downloader::downloadCached(ref store, const string & url_, bool unpack, string name, const Hash & expectedHash, string * effectiveUrl) { auto url = resolveUri(url_); @@ -295,7 +289,8 @@ Path Downloader::downloadCached(ref store, const string & url_, bool unpa time_t lastChecked; if (string2Int(ss[2], lastChecked) && lastChecked + ttl >= time(0)) { skip = true; - effectiveUrl = url_; + if (effectiveUrl) + *effectiveUrl = url_; } else if (!ss[1].empty()) { printMsg(lvlDebug, format("verifying previous ETag ‘%1%’") % ss[1]); expectedETag = ss[1]; @@ -311,7 +306,8 @@ Path Downloader::downloadCached(ref store, const string & url_, bool unpa DownloadOptions options; options.expectedETag = expectedETag; auto res = download(url, options); - effectiveUrl = res.effectiveUrl; + if (effectiveUrl) + *effectiveUrl = res.effectiveUrl; if (!res.cached) { ValidPathInfo info; diff --git a/src/libstore/download.hh b/src/libstore/download.hh index cb7de6ef1..011b85f47 100644 --- a/src/libstore/download.hh +++ b/src/libstore/download.hh @@ -32,12 +32,7 @@ struct Downloader virtual DownloadResult download(string url, const DownloadOptions & options) = 0; Path downloadCached(ref store, const string & url, bool unpack, string name = "", - const Hash & expectedHash = Hash()); - - /* Need to overload because can't have an rvalue default value for non-const reference */ - - Path downloadCached(ref store, const string & url, bool unpack, - string & effectiveUrl, const Hash & expectedHash = Hash()); + const Hash & expectedHash = Hash(), string * effectiveUrl = nullptr); enum Error { NotFound, Forbidden, Misc, Transient }; }; diff --git a/src/nix-channel/nix-channel.cc b/src/nix-channel/nix-channel.cc index 79c9d0ece..0f7858aa5 100755 --- a/src/nix-channel/nix-channel.cc +++ b/src/nix-channel/nix-channel.cc @@ -86,7 +86,7 @@ static void update(const StringSet & channelNames) // definition from a consistent location if the redirect changes mid-download. auto effectiveUrl = string{}; 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)); // If the URL contains a version number, append it to the name