aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/binary-cache-store.cc50
-rw-r--r--src/libstore/build/local-derivation-goal.cc14
-rw-r--r--src/libstore/build/substitution-goal.cc7
-rw-r--r--src/libstore/content-address.hh7
-rw-r--r--src/libstore/local-store.cc35
-rw-r--r--src/libstore/make-content-addressed.cc14
-rw-r--r--src/libstore/nar-info.hh4
-rw-r--r--src/libstore/path-info.cc64
-rw-r--r--src/libstore/path-info.hh4
-rw-r--r--src/libstore/store-api.cc28
-rw-r--r--src/libstore/store-api.hh2
11 files changed, 105 insertions, 124 deletions
diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc
index ac41add2c..9058bb8b1 100644
--- a/src/libstore/binary-cache-store.cc
+++ b/src/libstore/binary-cache-store.cc
@@ -307,17 +307,15 @@ StorePath BinaryCacheStore::addToStoreFromDump(Source & dump, std::string_view n
return addToStoreCommon(dump, repair, CheckSigs, [&](HashResult nar) {
ValidPathInfo info {
*this,
- {
- .name = std::string { name },
- .info = FixedOutputInfo {
- {
- .method = method,
- .hash = nar.first,
- },
- .references = {
- .others = references,
- .self = false,
- },
+ name,
+ FixedOutputInfo {
+ {
+ .method = method,
+ .hash = nar.first,
+ },
+ .references = {
+ .others = references,
+ .self = false,
},
},
nar.first,
@@ -427,17 +425,15 @@ StorePath BinaryCacheStore::addToStore(
return addToStoreCommon(*source, repair, CheckSigs, [&](HashResult nar) {
ValidPathInfo info {
*this,
- {
- .name = std::string { name },
- .info = FixedOutputInfo {
- {
- .method = method,
- .hash = h,
- },
- .references = {
- .others = references,
- .self = false,
- },
+ name,
+ FixedOutputInfo {
+ {
+ .method = method,
+ .hash = h,
+ },
+ .references = {
+ .others = references,
+ .self = false,
},
},
nar.first,
@@ -465,12 +461,10 @@ StorePath BinaryCacheStore::addTextToStore(
return addToStoreCommon(source, repair, CheckSigs, [&](HashResult nar) {
ValidPathInfo info {
*this,
- {
- .name = std::string { name },
- .info = TextInfo {
- { .hash = textHash },
- references,
- },
+ std::string { name },
+ TextInfo {
+ { .hash = textHash },
+ references,
},
nar.first,
};
diff --git a/src/libstore/build/local-derivation-goal.cc b/src/libstore/build/local-derivation-goal.cc
index bb4f92989..98f8cb061 100644
--- a/src/libstore/build/local-derivation-goal.cc
+++ b/src/libstore/build/local-derivation-goal.cc
@@ -2475,15 +2475,13 @@ DrvOutputs LocalDerivationGoal::registerOutputs()
auto got = caSink.finish().first;
ValidPathInfo newInfo0 {
worker.store,
- {
- .name = outputPathName(drv->name, outputName),
- .info = FixedOutputInfo {
- {
- .method = outputHash.method,
- .hash = got,
- },
- .references = rewriteRefs(),
+ outputPathName(drv->name, outputName),
+ FixedOutputInfo {
+ {
+ .method = outputHash.method,
+ .hash = got,
},
+ .references = rewriteRefs(),
},
Hash::dummy,
};
diff --git a/src/libstore/build/substitution-goal.cc b/src/libstore/build/substitution-goal.cc
index 994cb4ac2..87fed495c 100644
--- a/src/libstore/build/substitution-goal.cc
+++ b/src/libstore/build/substitution-goal.cc
@@ -95,10 +95,9 @@ void PathSubstitutionGoal::tryNext()
subs.pop_front();
if (ca) {
- subPath = sub->makeFixedOutputPathFromCA({
- .name = std::string { storePath.name() },
- .info = caWithoutRefs(*ca),
- });
+ subPath = sub->makeFixedOutputPathFromCA(
+ std::string { storePath.name() },
+ caWithoutRefs(*ca));
if (sub->storeDir == worker.store.storeDir)
assert(subPath == storePath);
} else if (sub->storeDir != worker.store.storeDir) {
diff --git a/src/libstore/content-address.hh b/src/libstore/content-address.hh
index 4a50bbee0..c49ab269f 100644
--- a/src/libstore/content-address.hh
+++ b/src/libstore/content-address.hh
@@ -132,11 +132,4 @@ typedef std::variant<
ContentAddressWithReferences caWithoutRefs(const ContentAddress &);
-struct StorePathDescriptor {
- std::string name;
- ContentAddressWithReferences info;
-
- GENERATE_CMP(StorePathDescriptor, me->name, me->info);
-};
-
}
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 2d03d2d8b..e55ccab84 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -1136,10 +1136,9 @@ void LocalStore::querySubstitutablePathInfos(const StorePathCAMap & paths, Subst
// Recompute store path so that we can use a different store root.
if (path.second) {
- subPath = makeFixedOutputPathFromCA({
- .name = std::string { path.first.name() },
- .info = caWithoutRefs(*path.second),
- });
+ subPath = makeFixedOutputPathFromCA(
+ path.first.name(),
+ caWithoutRefs(*path.second));
if (sub->storeDir == storeDir)
assert(subPath == path.first);
if (subPath != path.first)
@@ -1417,21 +1416,18 @@ StorePath LocalStore::addToStoreFromDump(Source & source0, std::string_view name
auto [hash, size] = hashSink->finish();
- auto desc = StorePathDescriptor {
- std::string { name },
- FixedOutputInfo {
- {
- .method = method,
- .hash = hash,
- },
- .references = {
- .others = references,
- .self = false,
- },
+ ContentAddressWithReferences desc = FixedOutputInfo {
+ {
+ .method = method,
+ .hash = hash,
+ },
+ .references = {
+ .others = references,
+ .self = false,
},
};
- auto dstPath = makeFixedOutputPathFromCA(desc);
+ auto dstPath = makeFixedOutputPathFromCA(name, desc);
addTempRoot(dstPath);
@@ -1475,7 +1471,12 @@ StorePath LocalStore::addToStoreFromDump(Source & source0, std::string_view name
optimisePath(realPath, repair);
- ValidPathInfo info { *this, std::move(desc), narHash.first };
+ ValidPathInfo info {
+ *this,
+ name,
+ std::move(desc),
+ narHash.first
+ };
info.narSize = narHash.second;
registerValidPath(info);
}
diff --git a/src/libstore/make-content-addressed.cc b/src/libstore/make-content-addressed.cc
index 09f615439..3ee64c77a 100644
--- a/src/libstore/make-content-addressed.cc
+++ b/src/libstore/make-content-addressed.cc
@@ -49,15 +49,13 @@ std::map<StorePath, StorePath> makeContentAddressed(
ValidPathInfo info {
dstStore,
- StorePathDescriptor {
- .name = std::string { path.name() },
- .info = FixedOutputInfo {
- {
- .method = FileIngestionMethod::Recursive,
- .hash = narModuloHash,
- },
- .references = std::move(refs),
+ path.name(),
+ FixedOutputInfo {
+ {
+ .method = FileIngestionMethod::Recursive,
+ .hash = narModuloHash,
},
+ .references = std::move(refs),
},
Hash::dummy,
};
diff --git a/src/libstore/nar-info.hh b/src/libstore/nar-info.hh
index f1e3aabbd..a4dccb397 100644
--- a/src/libstore/nar-info.hh
+++ b/src/libstore/nar-info.hh
@@ -16,8 +16,8 @@ struct NarInfo : ValidPathInfo
uint64_t fileSize = 0;
NarInfo() = delete;
- NarInfo(const Store & store, StorePathDescriptor && ca, Hash narHash)
- : ValidPathInfo(store, std::move(ca), narHash)
+ NarInfo(const Store & store, std::string && name, ContentAddressWithReferences && ca, Hash narHash)
+ : ValidPathInfo(store, std::move(name), std::move(ca), narHash)
{ }
NarInfo(StorePath && path, Hash narHash) : ValidPathInfo(std::move(path), narHash) { }
NarInfo(const ValidPathInfo & info) : ValidPathInfo(info) { }
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));
}
diff --git a/src/libstore/path-info.hh b/src/libstore/path-info.hh
index 476df79c2..663d94540 100644
--- a/src/libstore/path-info.hh
+++ b/src/libstore/path-info.hh
@@ -77,7 +77,7 @@ struct ValidPathInfo
void sign(const Store & store, const SecretKey & secretKey);
- std::optional<StorePathDescriptor> fullStorePathDescriptorOpt() const;
+ std::optional<ContentAddressWithReferences> contentAddressWithReferenences() const;
/* Return true iff the path is verifiably content-addressed. */
bool isContentAddressed(const Store & store) const;
@@ -100,7 +100,7 @@ struct ValidPathInfo
ValidPathInfo(const StorePath & path, Hash narHash) : path(path), narHash(narHash) { };
ValidPathInfo(const Store & store,
- StorePathDescriptor && ca, Hash narHash);
+ std::string_view name, ContentAddressWithReferences && ca, Hash narHash);
virtual ~ValidPathInfo() { }
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index c39e50d14..3c0c26706 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -209,17 +209,17 @@ StorePath Store::makeTextPath(std::string_view name, const TextInfo & info) cons
}
-StorePath Store::makeFixedOutputPathFromCA(const StorePathDescriptor & desc) const
+StorePath Store::makeFixedOutputPathFromCA(std::string_view name, const ContentAddressWithReferences & ca) const
{
// New template
return std::visit(overloaded {
[&](const TextInfo & ti) {
- return makeTextPath(desc.name, ti);
+ return makeTextPath(name, ti);
},
[&](const FixedOutputInfo & foi) {
- return makeFixedOutputPath(desc.name, foi);
+ return makeFixedOutputPath(name, foi);
}
- }, desc.info);
+ }, ca);
}
@@ -437,15 +437,13 @@ ValidPathInfo Store::addToStoreSlow(std::string_view name, const Path & srcPath,
ValidPathInfo info {
*this,
- StorePathDescriptor {
- std::string { name },
- FixedOutputInfo {
- {
- .method = method,
- .hash = hash,
- },
- .references = {},
+ name,
+ FixedOutputInfo {
+ {
+ .method = method,
+ .hash = hash,
},
+ .references = {},
},
narHash,
};
@@ -997,7 +995,8 @@ void copyStorePath(
if (info->ca && info->references.empty()) {
auto info2 = make_ref<ValidPathInfo>(*info);
info2->path = dstStore.makeFixedOutputPathFromCA(
- info->fullStorePathDescriptorOpt().value());
+ info->path.name(),
+ info->contentAddressWithReferenences().value());
if (dstStore.storeDir == srcStore.storeDir)
assert(info->path == info2->path);
info = info2;
@@ -1110,7 +1109,8 @@ std::map<StorePath, StorePath> copyPaths(
auto storePathForDst = storePathForSrc;
if (currentPathInfo.ca && currentPathInfo.references.empty()) {
storePathForDst = dstStore.makeFixedOutputPathFromCA(
- currentPathInfo.fullStorePathDescriptorOpt().value());
+ currentPathInfo.path.name(),
+ currentPathInfo.contentAddressWithReferenences().value());
if (dstStore.storeDir == srcStore.storeDir)
assert(storePathForDst == storePathForSrc);
if (storePathForDst != storePathForSrc)
diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh
index d77aea338..2d252db84 100644
--- a/src/libstore/store-api.hh
+++ b/src/libstore/store-api.hh
@@ -216,7 +216,7 @@ public:
StorePath makeTextPath(std::string_view name, const TextInfo & info) const;
- StorePath makeFixedOutputPathFromCA(const StorePathDescriptor & info) const;
+ StorePath makeFixedOutputPathFromCA(std::string_view name, const ContentAddressWithReferences & ca) const;
/* This is the preparatory part of addToStore(); it computes the
store path to which srcPath is to be copied. Returns the store