aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
diff options
context:
space:
mode:
authorMatthew Bauer <mjbauer95@gmail.com>2020-06-17 14:14:22 -0400
committerMatthew Bauer <mjbauer95@gmail.com>2020-06-17 14:15:08 -0400
commitbe50de1142b0600afebde32130e8561e28b63b41 (patch)
treecc4087df88bca35030e1c81aa5de65a488945d99 /src/libstore
parent8974755d1958824e732640f8131b0ed22ebd703b (diff)
Make sure references are empty for store path replacing
also copy info2 instead of casting
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/build.cc4
-rw-r--r--src/libstore/local-store.cc2
-rw-r--r--src/libstore/store-api.cc6
3 files changed, 6 insertions, 6 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index bc67ae31e..63cb70ef2 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -4437,8 +4437,8 @@ void SubstitutionGoal::tryNext()
}
if (info->path != storePath) {
- if (info->isContentAddressed(*sub)) {
- auto info2 = std::const_pointer_cast<ValidPathInfo>(std::shared_ptr<const ValidPathInfo>(info));
+ if (info->isContentAddressed(*sub) && info->references.empty()) {
+ auto info2 = std::make_shared<ValidPathInfo>(*info);
info2->path = storePath;
info = info2;
} else {
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index d08c7dc6a..3230312c9 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -863,7 +863,7 @@ void LocalStore::querySubstitutablePathInfos(const StorePathSet & paths,
try {
auto info = sub->queryPathInfo(subPath);
- if (sub->storeDir != storeDir && !info->isContentAddressed(*sub))
+ if (sub->storeDir != storeDir && !(info->isContentAddressed(*sub) && info->references.empty()))
continue;
auto narInfo = std::dynamic_pointer_cast<const NarInfo>(
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index 80a69717e..c8097da52 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -595,7 +595,7 @@ void copyStorePath(ref<Store> srcStore, ref<Store> dstStore,
uint64_t total = 0;
// recompute store path on the chance dstStore does it differently
- if (info->isContentAddressed(*srcStore)) {
+ if (info->isContentAddressed(*srcStore) && info->references.empty()) {
auto info2 = make_ref<ValidPathInfo>(*info);
info2->path = dstStore->makeFixedOutputPathFromCA(info->path.name(), info->ca);
if (dstStore->storeDir == srcStore->storeDir)
@@ -670,7 +670,7 @@ void copyPaths(ref<Store> srcStore, ref<Store> dstStore, const StorePathSet & st
auto info = srcStore->queryPathInfo(storePath);
auto storePathForDst = storePath;
- if (info->isContentAddressed(*srcStore)) {
+ if (info->isContentAddressed(*srcStore) && info->references.empty()) {
storePathForDst = dstStore->makeFixedOutputPathFromCA(storePath.name(), info->ca);
if (dstStore->storeDir == srcStore->storeDir)
assert(storePathForDst == storePath);
@@ -697,7 +697,7 @@ void copyPaths(ref<Store> srcStore, ref<Store> dstStore, const StorePathSet & st
auto info = srcStore->queryPathInfo(storePath);
auto storePathForDst = storePath;
- if (info->isContentAddressed(*srcStore)) {
+ if (info->isContentAddressed(*srcStore) && info->references.empty()) {
storePathForDst = dstStore->makeFixedOutputPathFromCA(storePath.name(), info->ca);
if (dstStore->storeDir == srcStore->storeDir)
assert(storePathForDst == storePath);