mirror of
https://github.com/NixOS/nix.git
synced 2025-11-21 09:49:36 +01:00
ValidPathInfo, NarInfo, turn funky constructor into static method
This is more flexible, and needed for me to be able to reshuffle the inheritance bureaucracy to make the JSON instances more precise.
This commit is contained in:
parent
465d627f7f
commit
74be28820c
14 changed files with 44 additions and 50 deletions
|
|
@ -124,25 +124,29 @@ Strings ValidPathInfo::shortRefs() const
|
|||
return refs;
|
||||
}
|
||||
|
||||
ValidPathInfo::ValidPathInfo(
|
||||
ValidPathInfo ValidPathInfo::makeFromCA(
|
||||
const StoreDirConfig & store, std::string_view name, ContentAddressWithReferences && ca, Hash narHash)
|
||||
: UnkeyedValidPathInfo(narHash)
|
||||
, path(store.makeFixedOutputPathFromCA(name, ca))
|
||||
{
|
||||
this->ca = ContentAddress{
|
||||
ValidPathInfo res{
|
||||
store.makeFixedOutputPathFromCA(name, ca),
|
||||
narHash,
|
||||
};
|
||||
res.ca = ContentAddress{
|
||||
.method = ca.getMethod(),
|
||||
.hash = ca.getHash(),
|
||||
};
|
||||
std::visit(
|
||||
res.references = std::visit(
|
||||
overloaded{
|
||||
[this](TextInfo && ti) { this->references = std::move(ti.references); },
|
||||
[this](FixedOutputInfo && foi) {
|
||||
this->references = std::move(foi.references.others);
|
||||
[&](TextInfo && ti) { return std::move(ti.references); },
|
||||
[&](FixedOutputInfo && foi) {
|
||||
auto references = std::move(foi.references.others);
|
||||
if (foi.references.self)
|
||||
this->references.insert(path);
|
||||
references.insert(res.path);
|
||||
return references;
|
||||
},
|
||||
},
|
||||
std::move(ca).raw);
|
||||
return res;
|
||||
}
|
||||
|
||||
nlohmann::json
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue