aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
diff options
context:
space:
mode:
authorThéophane Hufschmitt <theophane.hufschmitt@tweag.io>2022-06-08 15:13:11 +0200
committerThéophane Hufschmitt <theophane.hufschmitt@tweag.io>2022-06-08 15:13:11 +0200
commit480c2b6699e6afc6a746ba8a72319f197c3556ec (patch)
tree1dd6b9c58da69f58d569b343db8bb39a9f1624fd /src/libstore
parentcb0553ecd0122f693653c1ac82beb26d127ce3cd (diff)
Rewrite the CA paths when moving them between store
Bring back the possibility to copy CA paths with no reference (like the outputs of FO derivations or stuff imported at eval time) between stores that have a different prefix.
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/store-api.cc38
1 files changed, 24 insertions, 14 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index eeec6c6f7..61a12e84a 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -289,18 +289,6 @@ void Store::addMultipleToStore(
[&](const StorePath & path) {
auto & [info, source] = *infosMap.at(path);
- /* auto storePathForDst = info.storePath; */
- /* if (info->ca && info->references.empty()) { */
- /* storePathForDst = dstStore.makeFixedOutputPathFromCA(storePath.name(), *info->ca); */
- /* if (dstStore.storeDir == srcStore.storeDir) */
- /* assert(storePathForDst == storePath); */
- /* if (storePathForDst != storePath) */
- /* debug("replaced path '%s' to '%s' for substituter '%s'", */
- /* srcStore.printStorePath(storePath), */
- /* dstStore.printStorePath(storePathForDst), */
- /* dstStore.getUri()); */
- /* } */
- /* pathsMap.insert_or_assign(storePath, storePathForDst); */
if (isValidPath(info.path)) {
nrDone++;
@@ -1085,10 +1073,32 @@ std::map<StorePath, StorePath> copyPaths(
Store::PathsSource pathsToCopy;
+ auto computeStorePathForDst = [&](const ValidPathInfo & currentPathInfo) -> StorePath {
+ auto storePathForSrc = currentPathInfo.path;
+ auto storePathForDst = storePathForSrc;
+ if (currentPathInfo.ca && currentPathInfo.references.empty()) {
+ storePathForDst = dstStore.makeFixedOutputPathFromCA(storePathForSrc.name(), *currentPathInfo.ca);
+ if (dstStore.storeDir == srcStore.storeDir)
+ assert(storePathForDst == storePathForSrc);
+ if (storePathForDst != storePathForSrc)
+ debug("replaced path '%s' to '%s' for substituter '%s'",
+ srcStore.printStorePath(storePathForSrc),
+ dstStore.printStorePath(storePathForDst),
+ dstStore.getUri());
+ }
+ return storePathForDst;
+ };
+
for (auto & missingPath : sortedMissing) {
auto info = srcStore.queryPathInfo(missingPath);
- auto source = sinkToSource([&](Sink & sink) {
+ auto storePathForDst = computeStorePathForDst(*info);
+ pathsMap.insert_or_assign(missingPath, storePathForDst);
+
+ ValidPathInfo infoForDst = *info;
+ infoForDst.path = storePathForDst;
+
+ auto source = sinkToSource([&](Sink & sink) {
// We can reasonably assume that the copy will happen whenever we
// read the path, so log something about that at that point
auto srcUri = srcStore.getUri();
@@ -1101,7 +1111,7 @@ std::map<StorePath, StorePath> copyPaths(
srcStore.narFromPath(missingPath, sink);
});
- pathsToCopy.push_back(std::pair{*info, std::move(source)});
+ pathsToCopy.push_back(std::pair{infoForDst, std::move(source)});
}
dstStore.addMultipleToStore(pathsToCopy, act, repair, checkSigs);