aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/builtins
diff options
context:
space:
mode:
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 84c7d2082..03bb77488 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);