Fix DerivationOutput::fromJSON
This commit is contained in:
parent
e12efa3654
commit
2eb493ca51
1 changed files with 10 additions and 12 deletions
|
@ -997,15 +997,13 @@ DerivationOutput DerivationOutput::fromJSON(
|
||||||
for (const auto & [key, _] : json)
|
for (const auto & [key, _] : json)
|
||||||
keys.insert(key);
|
keys.insert(key);
|
||||||
|
|
||||||
auto methodAlgo = [&]() -> std::pair<FileIngestionMethod, HashType> {
|
auto methodAlgo = [&]() -> std::pair<ContentAddressMethod, HashType> {
|
||||||
std::string hashAlgo = json["hashAlgo"];
|
std::string hashAlgo = json["hashAlgo"];
|
||||||
auto method = FileIngestionMethod::Flat;
|
// remaining to parse, will be mutated by parsers
|
||||||
if (hashAlgo.substr(0, 2) == "r:") {
|
std::string_view s = hashAlgo;
|
||||||
method = FileIngestionMethod::Recursive;
|
ContentAddressMethod method = ContentAddressMethod::parsePrefix(s);
|
||||||
hashAlgo = hashAlgo.substr(2);
|
auto hashType = parseHashType(s);
|
||||||
}
|
return { std::move(method), std::move(hashType) };
|
||||||
auto hashType = parseHashType(hashAlgo);
|
|
||||||
return { method, hashType };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (keys == (std::set<std::string_view> { "path" })) {
|
if (keys == (std::set<std::string_view> { "path" })) {
|
||||||
|
@ -1018,7 +1016,7 @@ DerivationOutput DerivationOutput::fromJSON(
|
||||||
auto [method, hashType] = methodAlgo();
|
auto [method, hashType] = methodAlgo();
|
||||||
auto dof = DerivationOutput::CAFixed {
|
auto dof = DerivationOutput::CAFixed {
|
||||||
.ca = ContentAddressWithReferences::fromParts(
|
.ca = ContentAddressWithReferences::fromParts(
|
||||||
method,
|
std::move(method),
|
||||||
Hash::parseNonSRIUnprefixed((std::string) json["hash"], hashType),
|
Hash::parseNonSRIUnprefixed((std::string) json["hash"], hashType),
|
||||||
{}),
|
{}),
|
||||||
};
|
};
|
||||||
|
@ -1030,8 +1028,8 @@ DerivationOutput DerivationOutput::fromJSON(
|
||||||
else if (keys == (std::set<std::string_view> { "hashAlgo" })) {
|
else if (keys == (std::set<std::string_view> { "hashAlgo" })) {
|
||||||
auto [method, hashType] = methodAlgo();
|
auto [method, hashType] = methodAlgo();
|
||||||
return DerivationOutput::CAFloating {
|
return DerivationOutput::CAFloating {
|
||||||
.method = method,
|
.method = std::move(method),
|
||||||
.hashType = hashType,
|
.hashType = std::move(hashType),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1042,7 +1040,7 @@ DerivationOutput DerivationOutput::fromJSON(
|
||||||
else if (keys == (std::set<std::string_view> { "hashAlgo", "impure" })) {
|
else if (keys == (std::set<std::string_view> { "hashAlgo", "impure" })) {
|
||||||
auto [method, hashType] = methodAlgo();
|
auto [method, hashType] = methodAlgo();
|
||||||
return DerivationOutput::Impure {
|
return DerivationOutput::Impure {
|
||||||
.method = method,
|
.method = std::move(method),
|
||||||
.hashType = hashType,
|
.hashType = hashType,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue