1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-16 15:32:43 +01:00

DerivationOutput::parseHashInfo: Return a tuple

This commit is contained in:
Eelco Dolstra 2019-04-29 22:11:14 +02:00
parent c3b55a96a7
commit 76325ce5cd
4 changed files with 8 additions and 12 deletions

View file

@ -3106,8 +3106,7 @@ void DerivationGoal::registerOutputs()
hash). */ hash). */
if (fixedOutput) { if (fixedOutput) {
bool recursive; Hash h; auto [recursive, h] = i.second.parseHashInfo();
i.second.parseHashInfo(recursive, h);
if (!recursive) { if (!recursive) {
/* The output path should be a regular file without /* The output path should be a regular file without

View file

@ -9,21 +9,19 @@
namespace nix { namespace nix {
void DerivationOutput::parseHashInfo(bool & recursive, Hash & hash) const std::pair<bool, Hash> DerivationOutput::parseHashInfo() const
{ {
recursive = false; bool recursive = false;
string algo = hashAlgo; string algo = hashAlgo;
if (string(algo, 0, 2) == "r:") { if (string(algo, 0, 2) == "r:")
recursive = true; recursive = true;
algo = string(algo, 2);
}
HashType hashType = parseHashType(algo); HashType hashType = parseHashType(recursive ? string(algo, 2) : algo);
if (hashType == htUnknown) if (hashType == htUnknown)
throw Error(format("unknown hash algorithm '%1%'") % algo); throw Error(format("unknown hash algorithm '%1%'") % algo);
hash = Hash(this->hash, hashType); return {recursive, Hash(this->hash, hashType)};
} }

View file

@ -30,7 +30,7 @@ struct DerivationOutput
this->hashAlgo = hashAlgo; this->hashAlgo = hashAlgo;
this->hash = hash; this->hash = hash;
} }
void parseHashInfo(bool & recursive, Hash & hash) const; std::pair<bool, Hash> parseHashInfo() const;
}; };
typedef std::map<string, DerivationOutput> DerivationOutputs; typedef std::map<string, DerivationOutput> DerivationOutputs;

View file

@ -548,8 +548,7 @@ void LocalStore::checkDerivationOutputs(const Path & drvPath, const Derivation &
if (out == drv.outputs.end()) if (out == drv.outputs.end())
throw Error(format("derivation '%1%' does not have an output named 'out'") % drvPath); throw Error(format("derivation '%1%' does not have an output named 'out'") % drvPath);
bool recursive; Hash h; auto [recursive, h] = out->second.parseHashInfo();
out->second.parseHashInfo(recursive, h);
Path outPath = makeFixedOutputPath(recursive, h, drvName); Path outPath = makeFixedOutputPath(recursive, h, drvName);
StringPairs::const_iterator j = drv.env.find("out"); StringPairs::const_iterator j = drv.env.find("out");