aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/path-info.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2023-01-23 12:58:11 -0500
committerJohn Ericson <John.Ericson@Obsidian.Systems>2023-01-23 12:58:27 -0500
commit4540e7b940ca56db821fe7c7d7d79fafa488f55e (patch)
treedf688d2ea13f20f9225f08f90d9c327bf301d4ca /src/libstore/path-info.cc
parentc67e0cc58c5a74121d74a3f5cf9f9c2199a87093 (diff)
Don't add `StorePathDescriptor` for now
We don't need it yet, we can add it back later.
Diffstat (limited to 'src/libstore/path-info.cc')
-rw-r--r--src/libstore/path-info.cc64
1 files changed, 31 insertions, 33 deletions
diff --git a/src/libstore/path-info.cc b/src/libstore/path-info.cc
index 93f91e702..5944afd06 100644
--- a/src/libstore/path-info.cc
+++ b/src/libstore/path-info.cc
@@ -21,48 +21,45 @@ void ValidPathInfo::sign(const Store & store, const SecretKey & secretKey)
sigs.insert(secretKey.signDetached(fingerprint(store)));
}
-std::optional<StorePathDescriptor> ValidPathInfo::fullStorePathDescriptorOpt() const
+std::optional<ContentAddressWithReferences> ValidPathInfo::contentAddressWithReferenences() const
{
if (! ca)
return std::nullopt;
- return StorePathDescriptor {
- .name = std::string { path.name() },
- .info = std::visit(overloaded {
- [&](const TextHash & th) -> ContentAddressWithReferences {
- assert(references.count(path) == 0);
- return TextInfo {
- th,
- .references = references,
- };
- },
- [&](const FixedOutputHash & foh) -> ContentAddressWithReferences {
- auto refs = references;
- bool hasSelfReference = false;
- if (refs.count(path)) {
- hasSelfReference = true;
- refs.erase(path);
- }
- return FixedOutputInfo {
- foh,
- .references = {
- .others = std::move(refs),
- .self = hasSelfReference,
- },
- };
- },
- }, *ca),
- };
+ return std::visit(overloaded {
+ [&](const TextHash & th) -> ContentAddressWithReferences {
+ assert(references.count(path) == 0);
+ return TextInfo {
+ th,
+ .references = references,
+ };
+ },
+ [&](const FixedOutputHash & foh) -> ContentAddressWithReferences {
+ auto refs = references;
+ bool hasSelfReference = false;
+ if (refs.count(path)) {
+ hasSelfReference = true;
+ refs.erase(path);
+ }
+ return FixedOutputInfo {
+ foh,
+ .references = {
+ .others = std::move(refs),
+ .self = hasSelfReference,
+ },
+ };
+ },
+ }, *ca);
}
bool ValidPathInfo::isContentAddressed(const Store & store) const
{
- auto fullCaOpt = fullStorePathDescriptorOpt();
+ auto fullCaOpt = contentAddressWithReferenences();
if (! fullCaOpt)
return false;
- auto caPath = store.makeFixedOutputPathFromCA(*fullCaOpt);
+ auto caPath = store.makeFixedOutputPathFromCA(path.name(), *fullCaOpt);
bool res = caPath == path;
@@ -102,9 +99,10 @@ Strings ValidPathInfo::shortRefs() const
ValidPathInfo::ValidPathInfo(
const Store & store,
- StorePathDescriptor && info,
+ std::string_view name,
+ ContentAddressWithReferences && ca,
Hash narHash)
- : path(store.makeFixedOutputPathFromCA(info))
+ : path(store.makeFixedOutputPathFromCA(name, ca))
, narHash(narHash)
{
std::visit(overloaded {
@@ -118,7 +116,7 @@ ValidPathInfo::ValidPathInfo(
this->references.insert(path);
this->ca = std::move((FixedOutputHash &&) foi);
},
- }, std::move(info.info));
+ }, std::move(ca));
}