1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-30 15:48:00 +02:00

Add InputAccessor::fetchToStore()

This commit is contained in:
Eelco Dolstra 2022-08-11 20:03:22 +02:00
parent c0d33087c8
commit 2e0d63caf6
6 changed files with 59 additions and 27 deletions

View file

@ -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);