diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-06-29 14:04:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-29 14:04:12 +0200 |
commit | 58bc3b65789a6c1216abb0dfb4f553b2a6b7f479 (patch) | |
tree | f1d5f00b875a2818ece6f79b8a4b896bc744095c | |
parent | 64232f3ea6a0e6dbbb157d3e435c1b2b8fb05143 (diff) | |
parent | f4a5913125cb6a8ccfba556a0d75b19c2a5cfa37 (diff) |
Merge pull request #3729 from obsidiansystems/simpler-hased-mirror
hashed-mirrors: Use parsed derivation output rather than reconstructing it
-rw-r--r-- | src/libstore/builtins/fetchurl.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libstore/builtins/fetchurl.cc b/src/libstore/builtins/fetchurl.cc index 1cfe4a46a..e630cf6f1 100644 --- a/src/libstore/builtins/fetchurl.cc +++ b/src/libstore/builtins/fetchurl.cc @@ -58,13 +58,16 @@ void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData) } }; + /* We always have one output, and if it's a fixed-output derivation (as + checked below) it must be the only output */ + auto & output = drv.outputs.begin()->second; + /* Try the hashed mirrors first. */ - if (getAttr("outputHashMode") == "flat") + if (output.hash && output.hash->method == FileIngestionMethod::Flat) for (auto hashedMirror : settings.hashedMirrors.get()) try { if (!hasSuffix(hashedMirror, "/")) hashedMirror += '/'; - auto ht = parseHashTypeOpt(getAttr("outputHashAlgo")); - auto h = Hash(getAttr("outputHash"), ht); + auto & h = output.hash->hash; fetch(hashedMirror + printHashType(*h.type) + "/" + h.to_string(Base16, false)); return; } catch (Error & e) { |