aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/builtins
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-07-27 16:48:41 +0200
committerGitHub <noreply@github.com>2020-07-27 16:48:41 +0200
commita5f7d310dd10fe86b6f6aa1c2771c30f113741d4 (patch)
treeed365ca233fa7edfba9551539c4a903f109abef0 /src/libstore/builtins
parentd7c0f094cbcfe1ae4ccc3d54baec00b66ccb1ed0 (diff)
parentd5bb67cfa4da130a9949a9b4eb8aba6cb74ea5c7 (diff)
Merge pull request #3795 from obsidiansystems/optional-derivation-output-storepath
Only store hash in DerivationOutput for fixed output derivations
Diffstat (limited to 'src/libstore/builtins')
-rw-r--r--src/libstore/builtins/fetchurl.cc21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/libstore/builtins/fetchurl.cc b/src/libstore/builtins/fetchurl.cc
index e630cf6f1..017a633b5 100644
--- a/src/libstore/builtins/fetchurl.cc
+++ b/src/libstore/builtins/fetchurl.cc
@@ -63,16 +63,19 @@ void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData)
auto & output = drv.outputs.begin()->second;
/* Try the hashed mirrors first. */
- if (output.hash && output.hash->method == FileIngestionMethod::Flat)
- for (auto hashedMirror : settings.hashedMirrors.get())
- try {
- if (!hasSuffix(hashedMirror, "/")) hashedMirror += '/';
- auto & h = output.hash->hash;
- fetch(hashedMirror + printHashType(*h.type) + "/" + h.to_string(Base16, false));
- return;
- } catch (Error & e) {
- debug(e.what());
+ if (auto hash = std::get_if<DerivationOutputFixed>(&output.output)) {
+ if (hash->hash.method == FileIngestionMethod::Flat) {
+ for (auto hashedMirror : settings.hashedMirrors.get()) {
+ try {
+ if (!hasSuffix(hashedMirror, "/")) hashedMirror += '/';
+ fetch(hashedMirror + printHashType(*hash->hash.hash.type) + "/" + hash->hash.hash.to_string(Base16, false));
+ return;
+ } catch (Error & e) {
+ debug(e.what());
+ }
}
+ }
+ }
/* Otherwise try the specified URL. */
fetch(mainUrl);