aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
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/libstore
parentfecff16a6e8bffce9a404b1508fec375e83ec01e (diff)
parent406dbb7fce32f7d80b02f560d91c956698b58d6e (diff)
Merge remote-tracking branch 'obsidian/no-hash-type-unknown' into validPathInfo-ca-proper-datatype
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/build.cc6
-rw-r--r--src/libstore/builtins/fetchurl.cc4
-rw-r--r--src/libstore/content-address.cc4
-rw-r--r--src/libstore/derivations.cc4
-rw-r--r--src/libstore/export-import.cc2
-rw-r--r--src/libstore/local-store.cc4
6 files changed, 10 insertions, 14 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 7f79d6a2a..ea7319150 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -3723,8 +3723,8 @@ void DerivationGoal::registerOutputs()
/* Check the hash. In hash mode, move the path produced by
the derivation to its content-addressed location. */
Hash h2 = i.second.hash->method == FileIngestionMethod::Recursive
- ? hashPath(i.second.hash->hash.type, actualPath).first
- : hashFile(i.second.hash->hash.type, actualPath);
+ ? hashPath(*i.second.hash->hash.type, actualPath).first
+ : hashFile(*i.second.hash->hash.type, actualPath);
auto dest = worker.store.makeFixedOutputPath(i.second.hash->method, h2, i.second.path.name());
@@ -5004,7 +5004,7 @@ bool Worker::pathContentsGood(const StorePath & path)
if (!pathExists(store.printStorePath(path)))
res = false;
else {
- HashResult current = hashPath(info->narHash.type, store.printStorePath(path));
+ HashResult current = hashPath(*info->narHash.type, store.printStorePath(path));
Hash nullHash(HashType::SHA256);
res = info->narHash == nullHash || info->narHash == current.first;
}
diff --git a/src/libstore/builtins/fetchurl.cc b/src/libstore/builtins/fetchurl.cc
index b70e960f8..770df2927 100644
--- a/src/libstore/builtins/fetchurl.cc
+++ b/src/libstore/builtins/fetchurl.cc
@@ -63,9 +63,9 @@ void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData)
for (auto hashedMirror : settings.hashedMirrors.get())
try {
if (!hasSuffix(hashedMirror, "/")) hashedMirror += '/';
- auto ht = parseHashType(getAttr("outputHashAlgo"));
+ auto ht = parseHashTypeOpt(getAttr("outputHashAlgo"));
auto h = Hash(getAttr("outputHash"), ht);
- fetch(hashedMirror + printHashType(h.type) + "/" + h.to_string(Base::Base16, false));
+ fetch(hashedMirror + printHashType(*h.type) + "/" + h.to_string(Base::Base16, false));
return;
} catch (Error & e) {
debug(e.what());
diff --git a/src/libstore/content-address.cc b/src/libstore/content-address.cc
index 718c7ffc3..f30f53ff8 100644
--- a/src/libstore/content-address.cc
+++ b/src/libstore/content-address.cc
@@ -3,7 +3,7 @@
namespace nix {
std::string FileSystemHash::printMethodAlgo() const {
- return makeFileIngestionPrefix(method) + printHashType(hash.type);
+ return makeFileIngestionPrefix(method) + printHashType(*hash.type);
}
std::string makeFileIngestionPrefix(const FileIngestionMethod m) {
@@ -46,7 +46,7 @@ ContentAddress parseContentAddress(std::string_view rawCa) {
if (prefix == "text") {
auto hashTypeAndHash = rawCa.substr(prefixSeparator+1, string::npos);
Hash hash = Hash(string(hashTypeAndHash));
- if (hash.type != HashType::SHA256) {
+ if (*hash.type != HashType::SHA256) {
throw Error("parseContentAddress: the text hash should have type SHA256");
}
return TextHash { hash };
diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc
index f1569bf22..a522eb950 100644
--- a/src/libstore/derivations.cc
+++ b/src/libstore/derivations.cc
@@ -138,8 +138,6 @@ static DerivationOutput parseDerivationOutput(const Store & store, istringstream
hashAlgo = string(hashAlgo, 2);
}
const HashType hashType = parseHashType(hashAlgo);
- if (hashType == HashType::Unknown)
- throw Error("unknown hash hashAlgorithm '%s'", hashAlgo);
fsh = FileSystemHash {
std::move(method),
Hash(hash, hashType),
@@ -428,8 +426,6 @@ static DerivationOutput readDerivationOutput(Source & in, const Store & store)
hashAlgo = string(hashAlgo, 2);
}
HashType hashType = parseHashType(hashAlgo);
- if (hashType == HashType::Unknown)
- throw Error("unknown hash hashAlgorithm '%s'", hashAlgo);
fsh = FileSystemHash {
std::move(method),
Hash(hash, hashType),
diff --git a/src/libstore/export-import.cc b/src/libstore/export-import.cc
index c9731a6bd..aef5cc6da 100644
--- a/src/libstore/export-import.cc
+++ b/src/libstore/export-import.cc
@@ -55,7 +55,7 @@ void Store::exportPath(const StorePath & path, Sink & sink)
filesystem corruption from spreading to other machines.
Don't complain if the stored hash is zero (unknown). */
Hash hash = hashAndWriteSink.currentHash();
- if (hash != info->narHash && info->narHash != Hash(info->narHash.type))
+ if (hash != info->narHash && info->narHash != Hash(*info->narHash.type))
throw Error("hash of path '%s' has changed from '%s' to '%s'!",
printStorePath(path), info->narHash.to_string(), hash.to_string());
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 93697ae47..5f0053753 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -1269,9 +1269,9 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair)
std::unique_ptr<AbstractHashSink> hashSink;
if (info->ca || !info->references.count(info->path))
- hashSink = std::make_unique<HashSink>(info->narHash.type);
+ hashSink = std::make_unique<HashSink>(*info->narHash.type);
else
- hashSink = std::make_unique<HashModuloSink>(info->narHash.type, storePathToHash(printStorePath(info->path)));
+ hashSink = std::make_unique<HashModuloSink>(*info->narHash.type, storePathToHash(printStorePath(info->path)));
dumpPath(Store::toRealPath(i), *hashSink);
auto current = hashSink->finish();