Skip to content

Commit

Permalink
Merge pull request #4374 from NixOS/2.3-absolute-url-in-binary-caches
Browse files Browse the repository at this point in the history
Allow HTTP binary cache to request absolute uris
  • Loading branch information
edolstra authored Dec 16, 2020
2 parents 359c07b + 6de15f7 commit 8803753
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/libstore/http-binary-cache-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class HttpBinaryCacheStore : public BinaryCacheStore
checkEnabled();

try {
DownloadRequest request(cacheUri + "/" + path);
DownloadRequest request(makeRequest(path));
request.head = true;
getDownloader()->download(request);
return true;
Expand All @@ -100,7 +100,7 @@ class HttpBinaryCacheStore : public BinaryCacheStore
const std::string & data,
const std::string & mimeType) override
{
auto req = DownloadRequest(cacheUri + "/" + path);
auto req = makeRequest(path);
req.data = std::make_shared<string>(data); // FIXME: inefficient
req.mimeType = mimeType;
try {
Expand All @@ -112,8 +112,10 @@ class HttpBinaryCacheStore : public BinaryCacheStore

DownloadRequest makeRequest(const std::string & path)
{
DownloadRequest request(cacheUri + "/" + path);
return request;
return DownloadRequest(
hasPrefix(path, "https://") || hasPrefix(path, "http://") || hasPrefix(path, "file://")
? path
: cacheUri + "/" + path);
}

void getFile(const std::string & path, Sink & sink) override
Expand Down

0 comments on commit 8803753

Please sign in to comment.