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

No inheritance for TextInfo and FixedOutputInfo

This commit is contained in:
John Ericson 2023-02-28 12:13:43 -05:00
parent 85bb865d20
commit d381248ec0
17 changed files with 33 additions and 31 deletions

View file

@ -309,7 +309,7 @@ StorePath BinaryCacheStore::addToStoreFromDump(Source & dump, std::string_view n
*this,
name,
FixedOutputInfo {
{
.hash = {
.method = method,
.hash = nar.first,
},
@ -427,7 +427,7 @@ StorePath BinaryCacheStore::addToStore(
*this,
name,
FixedOutputInfo {
{
.hash = {
.method = method,
.hash = h,
},

View file

@ -2442,7 +2442,7 @@ DrvOutputs LocalDerivationGoal::registerOutputs()
worker.store,
outputPathName(drv->name, outputName),
FixedOutputInfo {
{
.hash = {
.method = outputHash.method,
.hash = got,
},

View file

@ -166,13 +166,13 @@ ContentAddressWithReferences caWithoutRefs(const ContentAddress & ca) {
return std::visit(overloaded {
[&](const TextHash & h) -> ContentAddressWithReferences {
return TextInfo {
h,
.hash = h,
.references = {},
};
},
[&](const FixedOutputHash & h) -> ContentAddressWithReferences {
return FixedOutputInfo {
h,
.hash = h,
.references = {},
};
},

View file

@ -111,18 +111,20 @@ struct StoreReferences {
*/
// This matches the additional info that we need for makeTextPath
struct TextInfo : TextHash {
struct TextInfo {
TextHash hash;
// References for the paths, self references disallowed
StorePathSet references;
GENERATE_CMP(TextInfo, *(const TextHash *)me, me->references);
GENERATE_CMP(TextInfo, me->hash, me->references);
};
struct FixedOutputInfo : FixedOutputHash {
struct FixedOutputInfo {
FixedOutputHash hash;
// References for the paths
StoreReferences references;
GENERATE_CMP(FixedOutputInfo, *(const FixedOutputHash *)me, me->references);
GENERATE_CMP(FixedOutputInfo, me->hash, me->references);
};
typedef std::variant<

View file

@ -1415,7 +1415,7 @@ StorePath LocalStore::addToStoreFromDump(Source & source0, std::string_view name
auto [hash, size] = hashSink->finish();
ContentAddressWithReferences desc = FixedOutputInfo {
{
.hash = {
.method = method,
.hash = hash,
},

View file

@ -52,7 +52,7 @@ std::map<StorePath, StorePath> makeContentAddressed(
dstStore,
path.name(),
FixedOutputInfo {
{
.hash = {
.method = FileIngestionMethod::Recursive,
.hash = narModuloHash,
},

View file

@ -30,7 +30,7 @@ std::optional<ContentAddressWithReferences> ValidPathInfo::contentAddressWithRef
[&](const TextHash & th) -> ContentAddressWithReferences {
assert(references.count(path) == 0);
return TextInfo {
th,
.hash = th,
.references = references,
};
},
@ -42,7 +42,7 @@ std::optional<ContentAddressWithReferences> ValidPathInfo::contentAddressWithRef
refs.erase(path);
}
return FixedOutputInfo {
foh,
.hash = foh,
.references = {
.others = std::move(refs),
.self = hasSelfReference,

View file

@ -184,15 +184,15 @@ static std::string makeType(
StorePath Store::makeFixedOutputPath(std::string_view name, const FixedOutputInfo & info) const
{
if (info.hash.type == htSHA256 && info.method == FileIngestionMethod::Recursive) {
return makeStorePath(makeType(*this, "source", info.references), info.hash, name);
if (info.hash.hash.type == htSHA256 && info.hash.method == FileIngestionMethod::Recursive) {
return makeStorePath(makeType(*this, "source", info.references), info.hash.hash, name);
} else {
assert(info.references.size() == 0);
return makeStorePath("output:out",
hashString(htSHA256,
"fixed:out:"
+ makeFileIngestionPrefix(info.method)
+ info.hash.to_string(Base16, true) + ":"),
+ makeFileIngestionPrefix(info.hash.method)
+ info.hash.hash.to_string(Base16, true) + ":"),
name);
}
}
@ -200,13 +200,13 @@ StorePath Store::makeFixedOutputPath(std::string_view name, const FixedOutputInf
StorePath Store::makeTextPath(std::string_view name, const TextInfo & info) const
{
assert(info.hash.type == htSHA256);
assert(info.hash.hash.type == htSHA256);
return makeStorePath(
makeType(*this, "text", StoreReferences {
.others = info.references,
.self = false,
}),
info.hash,
info.hash.hash,
name);
}
@ -232,7 +232,7 @@ std::pair<StorePath, Hash> Store::computeStorePathForPath(std::string_view name,
? hashPath(hashAlgo, srcPath, filter).first
: hashFile(hashAlgo, srcPath);
FixedOutputInfo caInfo {
{
.hash = {
.method = method,
.hash = h,
},
@ -441,7 +441,7 @@ ValidPathInfo Store::addToStoreSlow(std::string_view name, const Path & srcPath,
*this,
name,
FixedOutputInfo {
{
.hash = {
.method = method,
.hash = hash,
},