aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-06-02 23:30:38 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-06-03 04:44:24 +0000
commit3c78ac348c3a32fa6d78d3c56645901513c2e731 (patch)
treeb4ff0079484b825f884eb98ff88655142d386f58 /src/libexpr
parentfecff16a6e8bffce9a404b1508fec375e83ec01e (diff)
parent406dbb7fce32f7d80b02f560d91c956698b58d6e (diff)
Merge remote-tracking branch 'obsidian/no-hash-type-unknown' into validPathInfo-ca-proper-datatype
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/primops.cc18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index b6e889e15..98742e0c8 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -718,14 +718,14 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
if (outputs.size() != 1 || *(outputs.begin()) != "out")
throw Error(format("multiple outputs are not supported in fixed-output derivations, at %1%") % posDrvName);
- HashType ht = outputHashAlgo.empty() ? HashType::Unknown : parseHashType(outputHashAlgo);
+ std::optional<HashType> ht = parseHashTypeOpt(outputHashAlgo);
Hash h(*outputHash, ht);
auto outPath = state.store->makeFixedOutputPath(ingestionMethod, h, drvName);
if (!jsonObject) drv.env["out"] = state.store->printStorePath(outPath);
drv.outputs.insert_or_assign("out", DerivationOutput(
- std::move(outPath),
- FileSystemHash(ingestionMethod, std::move(h))));
+ std::move(outPath),
+ FileSystemHash(ingestionMethod, std::move(h))));
}
else {
@@ -931,14 +931,14 @@ static void prim_findFile(EvalState & state, const Pos & pos, Value * * args, Va
static void prim_hashFile(EvalState & state, const Pos & pos, Value * * args, Value & v)
{
string type = state.forceStringNoCtx(*args[0], pos);
- HashType ht = parseHashType(type);
- if (ht == HashType::Unknown)
+ std::optional<HashType> ht = parseHashType(type);
+ if (!ht)
throw Error(format("unknown hash type '%1%', at %2%") % type % pos);
PathSet context; // discarded
Path p = state.coerceToPath(pos, *args[1], context);
- mkString(v, hashFile(ht, state.checkSourcePath(p)).to_string(Base::Base16, false), context);
+ mkString(v, hashFile(*ht, state.checkSourcePath(p)).to_string(Base::Base16, false), context);
}
/* Read a directory (without . or ..) */
@@ -1809,14 +1809,14 @@ static void prim_stringLength(EvalState & state, const Pos & pos, Value * * args
static void prim_hashString(EvalState & state, const Pos & pos, Value * * args, Value & v)
{
string type = state.forceStringNoCtx(*args[0], pos);
- HashType ht = parseHashType(type);
- if (ht == HashType::Unknown)
+ std::optional<HashType> ht = parseHashType(type);
+ if (!ht)
throw Error(format("unknown hash type '%1%', at %2%") % type % pos);
PathSet context; // discarded
string s = state.forceString(*args[1], context, pos);
- mkString(v, hashString(ht, s).to_string(Base::Base16, false), context);
+ mkString(v, hashString(*ht, s).to_string(Base::Base16, false), context);
}