forked from lix-project/lix
Fix makeContentAddressed() on self-references
LocalStore::addToStore() since
79ae9e4558
expects a regular NAR hash,
rather than a NAR hash modulo self-references. Fixes #6300.
Also, makeContentAddressed() now rewrites the entire closure (so 'nix
store make-content-addressable' no longer needs '-r'). See #6301.
This commit is contained in:
parent
545c2d0d8c
commit
f18607549c
|
@ -8,9 +8,10 @@ std::map<StorePath, StorePath> makeContentAddressed(
|
||||||
Store & dstStore,
|
Store & dstStore,
|
||||||
const StorePathSet & storePaths)
|
const StorePathSet & storePaths)
|
||||||
{
|
{
|
||||||
// FIXME: use closure of storePaths.
|
StorePathSet closure;
|
||||||
|
srcStore.computeFSClosure(storePaths, closure);
|
||||||
|
|
||||||
auto paths = srcStore.topoSortPaths(storePaths);
|
auto paths = srcStore.topoSortPaths(closure);
|
||||||
|
|
||||||
std::reverse(paths.begin(), paths.end());
|
std::reverse(paths.begin(), paths.end());
|
||||||
|
|
||||||
|
@ -46,29 +47,29 @@ std::map<StorePath, StorePath> makeContentAddressed(
|
||||||
HashModuloSink hashModuloSink(htSHA256, oldHashPart);
|
HashModuloSink hashModuloSink(htSHA256, oldHashPart);
|
||||||
hashModuloSink(sink.s);
|
hashModuloSink(sink.s);
|
||||||
|
|
||||||
auto narHash = hashModuloSink.finish().first;
|
auto narModuloHash = hashModuloSink.finish().first;
|
||||||
|
|
||||||
ValidPathInfo info {
|
auto dstPath = dstStore.makeFixedOutputPath(
|
||||||
dstStore.makeFixedOutputPath(FileIngestionMethod::Recursive, narHash, path.name(), references, hasSelfReference),
|
FileIngestionMethod::Recursive, narModuloHash, path.name(), references, hasSelfReference);
|
||||||
narHash,
|
|
||||||
};
|
printInfo("rewroting '%s' to '%s'", pathS, srcStore.printStorePath(dstPath));
|
||||||
|
|
||||||
|
StringSink sink2;
|
||||||
|
RewritingSink rsink2(oldHashPart, std::string(dstPath.hashPart()), sink2);
|
||||||
|
rsink2(sink.s);
|
||||||
|
rsink2.flush();
|
||||||
|
|
||||||
|
ValidPathInfo info { dstPath, hashString(htSHA256, sink2.s) };
|
||||||
info.references = std::move(references);
|
info.references = std::move(references);
|
||||||
if (hasSelfReference) info.references.insert(info.path);
|
if (hasSelfReference) info.references.insert(info.path);
|
||||||
info.narSize = sink.s.size();
|
info.narSize = sink.s.size();
|
||||||
info.ca = FixedOutputHash {
|
info.ca = FixedOutputHash {
|
||||||
.method = FileIngestionMethod::Recursive,
|
.method = FileIngestionMethod::Recursive,
|
||||||
.hash = info.narHash,
|
.hash = narModuloHash,
|
||||||
};
|
};
|
||||||
|
|
||||||
printInfo("rewrote '%s' to '%s'", pathS, srcStore.printStorePath(info.path));
|
StringSource source(sink2.s);
|
||||||
|
dstStore.addToStore(info, source);
|
||||||
auto source = sinkToSource([&](Sink & nextSink) {
|
|
||||||
RewritingSink rsink2(oldHashPart, std::string(info.path.hashPart()), nextSink);
|
|
||||||
rsink2(sink.s);
|
|
||||||
rsink2.flush();
|
|
||||||
});
|
|
||||||
|
|
||||||
dstStore.addToStore(info, *source);
|
|
||||||
|
|
||||||
remappings.insert_or_assign(std::move(path), std::move(info.path));
|
remappings.insert_or_assign(std::move(path), std::move(info.path));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue