Don't add StorePathDescriptor for now

We don't need it yet, we can add it back later.
This commit is contained in:
John Ericson 2023-01-23 12:58:11 -05:00
parent c67e0cc58c
commit 4540e7b940
14 changed files with 126 additions and 151 deletions

View file

@ -72,16 +72,14 @@ DownloadFileResult downloadFile(
auto hash = hashString(htSHA256, res.data);
ValidPathInfo info {
*store,
{
.name = name,
.info = FixedOutputInfo {
name,
FixedOutputInfo {
{
.method = FileIngestionMethod::Flat,
.hash = hash,
},
.references = {},
},
},
hashString(htSHA256, sink.s),
};
info.narSize = sink.s.size();

View file

@ -307,9 +307,8 @@ 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 {
name,
FixedOutputInfo {
{
.method = method,
.hash = nar.first,
@ -319,7 +318,6 @@ StorePath BinaryCacheStore::addToStoreFromDump(Source & dump, std::string_view n
.self = false,
},
},
},
nar.first,
};
info.narSize = nar.second;
@ -427,9 +425,8 @@ StorePath BinaryCacheStore::addToStore(
return addToStoreCommon(*source, repair, CheckSigs, [&](HashResult nar) {
ValidPathInfo info {
*this,
{
.name = std::string { name },
.info = FixedOutputInfo {
name,
FixedOutputInfo {
{
.method = method,
.hash = h,
@ -439,7 +436,6 @@ StorePath BinaryCacheStore::addToStore(
.self = false,
},
},
},
nar.first,
};
info.narSize = nar.second;
@ -465,13 +461,11 @@ StorePath BinaryCacheStore::addTextToStore(
return addToStoreCommon(source, repair, CheckSigs, [&](HashResult nar) {
ValidPathInfo info {
*this,
{
.name = std::string { name },
.info = TextInfo {
std::string { name },
TextInfo {
{ .hash = textHash },
references,
},
},
nar.first,
};
info.narSize = nar.second;

View file

@ -2475,16 +2475,14 @@ DrvOutputs LocalDerivationGoal::registerOutputs()
auto got = caSink.finish().first;
ValidPathInfo newInfo0 {
worker.store,
{
.name = outputPathName(drv->name, outputName),
.info = FixedOutputInfo {
outputPathName(drv->name, outputName),
FixedOutputInfo {
{
.method = outputHash.method,
.hash = got,
},
.references = rewriteRefs(),
},
},
Hash::dummy,
};
if (*scratchPath != newInfo0.path) {

View file

@ -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) {

View file

@ -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);
};
}

View file

@ -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,9 +1416,7 @@ StorePath LocalStore::addToStoreFromDump(Source & source0, std::string_view name
auto [hash, size] = hashSink->finish();
auto desc = StorePathDescriptor {
std::string { name },
FixedOutputInfo {
ContentAddressWithReferences desc = FixedOutputInfo {
{
.method = method,
.hash = hash,
@ -1428,10 +1425,9 @@ StorePath LocalStore::addToStoreFromDump(Source & source0, std::string_view name
.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);
}

View file

@ -49,16 +49,14 @@ std::map<StorePath, StorePath> makeContentAddressed(
ValidPathInfo info {
dstStore,
StorePathDescriptor {
.name = std::string { path.name() },
.info = FixedOutputInfo {
path.name(),
FixedOutputInfo {
{
.method = FileIngestionMethod::Recursive,
.hash = narModuloHash,
},
.references = std::move(refs),
},
},
Hash::dummy,
};

View file

@ -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) { }

View file

@ -21,14 +21,12 @@ 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 {
return std::visit(overloaded {
[&](const TextHash & th) -> ContentAddressWithReferences {
assert(references.count(path) == 0);
return TextInfo {
@ -51,18 +49,17 @@ std::optional<StorePathDescriptor> ValidPathInfo::fullStorePathDescriptorOpt() c
},
};
},
}, *ca),
};
}, *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));
}

View file

@ -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() { }

View file

@ -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,8 +437,7 @@ ValidPathInfo Store::addToStoreSlow(std::string_view name, const Path & srcPath,
ValidPathInfo info {
*this,
StorePathDescriptor {
std::string { name },
name,
FixedOutputInfo {
{
.method = method,
@ -446,7 +445,6 @@ ValidPathInfo Store::addToStoreSlow(std::string_view name, const Path & srcPath,
},
.references = {},
},
},
narHash,
};
info.narSize = narSize;
@ -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)

View file

@ -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

View file

@ -43,16 +43,14 @@ struct CmdAddToStore : MixDryRun, StoreCommand
ValidPathInfo info {
*store,
StorePathDescriptor {
.name = *namePart,
.info = FixedOutputInfo {
std::move(*namePart),
FixedOutputInfo {
{
.method = std::move(ingestionMethod),
.hash = std::move(hash),
},
.references = {},
},
},
narHash,
};
info.narSize = sink.s.size();

View file

@ -200,7 +200,6 @@ struct ProfileManifest
ValidPathInfo info {
*store,
StorePathDescriptor {
"profile",
FixedOutputInfo {
{
@ -212,7 +211,6 @@ struct ProfileManifest
.self = false,
},
},
},
narHash,
};
info.narSize = sink.s.size();