forked from lix-project/lix
addPath: allow paths with references
Since 4806f2f6b0
, we can't have paths with
references passed to builtins.{path,filterSource}. This prevents many cases
of those functions called on IFD outputs from working. Resolve this by
passing the references found in the original path to the added path.
This commit is contained in:
parent
b9234142f5
commit
9d4dcff37a
|
@ -1859,12 +1859,12 @@ static void addPath(
|
||||||
// be rewritten to the actual output).
|
// be rewritten to the actual output).
|
||||||
state.realiseContext(context);
|
state.realiseContext(context);
|
||||||
|
|
||||||
|
StorePathSet refs = StorePathSet();
|
||||||
|
|
||||||
if (state.store->isInStore(path)) {
|
if (state.store->isInStore(path)) {
|
||||||
auto [storePath, subPath] = state.store->toStorePath(path);
|
auto [storePath, subPath] = state.store->toStorePath(path);
|
||||||
auto info = state.store->queryPathInfo(storePath);
|
// FIXME: we should scanForReferences on the path before adding it
|
||||||
if (!info->references.empty())
|
refs = state.store->queryPathInfo(storePath)->references;
|
||||||
throw EvalError("store path '%s' is not allowed to have references",
|
|
||||||
state.store->printStorePath(storePath));
|
|
||||||
path = state.store->toRealPath(storePath) + subPath;
|
path = state.store->toRealPath(storePath) + subPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1904,7 +1904,7 @@ static void addPath(
|
||||||
if (!expectedHash || !state.store->isValidPath(*expectedStorePath)) {
|
if (!expectedHash || !state.store->isValidPath(*expectedStorePath)) {
|
||||||
dstPath = state.store->printStorePath(settings.readOnlyMode
|
dstPath = state.store->printStorePath(settings.readOnlyMode
|
||||||
? state.store->computeStorePathForPath(name, path, method, htSHA256, filter).first
|
? state.store->computeStorePathForPath(name, path, method, htSHA256, filter).first
|
||||||
: state.store->addToStore(name, path, method, htSHA256, filter, state.repair));
|
: state.store->addToStore(name, path, method, htSHA256, filter, state.repair, refs));
|
||||||
if (expectedHash && expectedStorePath != state.store->parseStorePath(dstPath))
|
if (expectedHash && expectedStorePath != state.store->parseStorePath(dstPath))
|
||||||
throw Error("store path mismatch in (possibly filtered) path added from '%s'", path);
|
throw Error("store path mismatch in (possibly filtered) path added from '%s'", path);
|
||||||
} else
|
} else
|
||||||
|
|
|
@ -314,7 +314,7 @@ StorePath BinaryCacheStore::addToStoreFromDump(Source & dump, const string & nam
|
||||||
unsupported("addToStoreFromDump");
|
unsupported("addToStoreFromDump");
|
||||||
return addToStoreCommon(dump, repair, CheckSigs, [&](HashResult nar) {
|
return addToStoreCommon(dump, repair, CheckSigs, [&](HashResult nar) {
|
||||||
ValidPathInfo info {
|
ValidPathInfo info {
|
||||||
makeFixedOutputPath(method, nar.first, name),
|
makeFixedOutputPath(method, nar.first, name, references),
|
||||||
nar.first,
|
nar.first,
|
||||||
};
|
};
|
||||||
info.narSize = nar.second;
|
info.narSize = nar.second;
|
||||||
|
@ -405,7 +405,7 @@ StorePath BinaryCacheStore::addToStore(const string & name, const Path & srcPath
|
||||||
});
|
});
|
||||||
return addToStoreCommon(*source, repair, CheckSigs, [&](HashResult nar) {
|
return addToStoreCommon(*source, repair, CheckSigs, [&](HashResult nar) {
|
||||||
ValidPathInfo info {
|
ValidPathInfo info {
|
||||||
makeFixedOutputPath(method, h, name),
|
makeFixedOutputPath(method, h, name, references),
|
||||||
nar.first,
|
nar.first,
|
||||||
};
|
};
|
||||||
info.narSize = nar.second;
|
info.narSize = nar.second;
|
||||||
|
|
|
@ -402,8 +402,6 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
||||||
return store->queryPathInfo(path);
|
return store->queryPathInfo(path);
|
||||||
},
|
},
|
||||||
[&](FixedOutputHashMethod & fohm) {
|
[&](FixedOutputHashMethod & fohm) {
|
||||||
// if (!refs.empty())
|
|
||||||
// throw UnimplementedError("cannot yet have refs with flat or nar-hashed data");
|
|
||||||
auto path = store->addToStoreFromDump(source, name, fohm.fileIngestionMethod, fohm.hashType, repair, refs);
|
auto path = store->addToStoreFromDump(source, name, fohm.fileIngestionMethod, fohm.hashType, repair, refs);
|
||||||
return store->queryPathInfo(path);
|
return store->queryPathInfo(path);
|
||||||
},
|
},
|
||||||
|
|
|
@ -1358,7 +1358,7 @@ StorePath LocalStore::addToStoreFromDump(Source & source0, const string & name,
|
||||||
|
|
||||||
auto [hash, size] = hashSink->finish();
|
auto [hash, size] = hashSink->finish();
|
||||||
|
|
||||||
auto dstPath = makeFixedOutputPath(method, hash, name);
|
auto dstPath = makeFixedOutputPath(method, hash, name, references);
|
||||||
|
|
||||||
addTempRoot(dstPath);
|
addTempRoot(dstPath);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue