mirror of
https://github.com/NixOS/nix
synced 2025-07-02 13:31:48 +02:00
Add InputAccessor::fetchToStore()
This commit is contained in:
parent
c0d33087c8
commit
2e0d63caf6
6 changed files with 59 additions and 27 deletions
|
@ -2257,13 +2257,7 @@ StorePath EvalState::copyPathToStore(PathSet & context, const SourcePath & path)
|
|||
auto dstPath = i != srcToStore.end()
|
||||
? i->second
|
||||
: [&]() {
|
||||
auto source = sinkToSource([&](Sink & sink) {
|
||||
path.dumpPath(sink);
|
||||
});
|
||||
auto dstPath =
|
||||
settings.readOnlyMode
|
||||
? store->computeStorePathFromDump(*source, path.baseName()).first
|
||||
: store->addToStoreFromDump(*source, path.baseName(), FileIngestionMethod::Recursive, htSHA256, repair);
|
||||
auto dstPath = path.fetchToStore(store, path.baseName(), nullptr, repair);
|
||||
allowPath(dstPath);
|
||||
srcToStore.insert_or_assign(path, dstPath);
|
||||
printMsg(lvlChatty, "copied source '%1%' -> '%2%'", path, store->printStorePath(dstPath));
|
||||
|
|
|
@ -2006,7 +2006,8 @@ static void addPath(
|
|||
}
|
||||
#endif
|
||||
|
||||
PathFilter filter = filterFun ? ([&](const Path & p) {
|
||||
std::unique_ptr<PathFilter> filter;
|
||||
if (filterFun) filter = std::make_unique<PathFilter>([&](const Path & p) {
|
||||
SourcePath path2{path.accessor, CanonPath(p)};
|
||||
|
||||
auto st = path2.lstat();
|
||||
|
@ -2025,7 +2026,7 @@ static void addPath(
|
|||
state.callFunction(*filterFun, 2, args, res, pos);
|
||||
|
||||
return state.forceBool(res, pos);
|
||||
}) : defaultPathFilter;
|
||||
});
|
||||
|
||||
std::optional<StorePath> expectedStorePath;
|
||||
if (expectedHash)
|
||||
|
@ -2036,13 +2037,10 @@ static void addPath(
|
|||
// store on-demand.
|
||||
|
||||
if (!expectedHash || !state.store->isValidPath(*expectedStorePath)) {
|
||||
auto source = sinkToSource([&](Sink & sink) {
|
||||
path.dumpPath(sink, filter);
|
||||
});
|
||||
auto dstPath =
|
||||
settings.readOnlyMode
|
||||
? state.store->computeStorePathFromDump(*source, name, method, htSHA256, refs).first
|
||||
: state.store->addToStoreFromDump(*source, name, method, htSHA256, state.repair);
|
||||
// FIXME
|
||||
if (method != FileIngestionMethod::Recursive)
|
||||
throw Error("'recursive = false' is not implemented");
|
||||
auto dstPath = path.fetchToStore(state.store, name, filter.get(), state.repair);
|
||||
if (expectedHash && expectedStorePath != dstPath)
|
||||
state.debugThrowLastTrace(Error("store path mismatch in (possibly filtered) path added from '%s'", path));
|
||||
state.allowAndSetStorePathString(dstPath, v);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue