diff options
author | Carlo Nucera <carlo.nucera@protonmail.com> | 2020-06-02 16:13:08 -0400 |
---|---|---|
committer | Carlo Nucera <carlo.nucera@protonmail.com> | 2020-06-02 16:13:08 -0400 |
commit | a5cdf1867efdf50f8cef324bbc36d1b840e13f8c (patch) | |
tree | 5c344ccc8ea408528e3fa00121b0712d48a2c9e6 /src | |
parent | fd2eb41e6433e72516ae149949b8b0050305293d (diff) |
Add assertions for SHA256 in fixed case
Diffstat (limited to 'src')
-rw-r--r-- | src/libstore/content-address.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libstore/content-address.cc b/src/libstore/content-address.cc index 421127f5a..4c3af18fd 100644 --- a/src/libstore/content-address.cc +++ b/src/libstore/content-address.cc @@ -51,10 +51,14 @@ ContentAddress parseContentAddress(std::string_view rawCa) { auto methodAndHash = rawCa.substr(prefixSeparator+1, string::npos); if (methodAndHash.substr(0,2) == "r:") { std::string_view hashRaw = methodAndHash.substr(2,string::npos); - return FileSystemHash { FileIngestionMethod::Recursive, Hash(string(hashRaw)) }; + Hash hash = Hash(string(hashRaw)); + assert(hash.type == HashType::SHA256); + return FileSystemHash { FileIngestionMethod::Recursive, hash }; } else { std::string_view hashRaw = methodAndHash; - return FileSystemHash { FileIngestionMethod::Flat, Hash(string(hashRaw)) }; + Hash hash = Hash(string(hashRaw)); + assert(hash.type == HashType::SHA256); + return FileSystemHash { FileIngestionMethod::Flat, hash }; } } else { throw "parseContentAddress: format not recognized; has to be text or fixed"; |