libfetchers: asyncify fetchToStore
Change-Id: I0153cefbe974137ab3d4fd9218c8a77137976f8c
This commit is contained in:
@@ -47,7 +47,9 @@ std::optional<DerivedPathWithInfo> InstallableValue::trySinglePathToDerivedPaths
|
||||
)
|
||||
{
|
||||
if (v.type() == nPath) {
|
||||
auto storePath = fetchToStore(*evaluator->store, state.ctx.paths.checkSourcePath(v.path()));
|
||||
auto storePath = state.aio.blockOn(
|
||||
fetchToStore(*evaluator->store, state.ctx.paths.checkSourcePath(v.path()))
|
||||
);
|
||||
return {{
|
||||
.path = DerivedPath::Opaque {
|
||||
.path = std::move(storePath),
|
||||
|
||||
+11
-4
@@ -2366,13 +2366,20 @@ try {
|
||||
|
||||
auto dstPath = i != srcToStore.end()
|
||||
? i->second
|
||||
: [&]() {
|
||||
auto dstPath = fetchToStore(*store, checkSourcePath(path), path.baseName(), FileIngestionMethod::Recursive, nullptr, repair);
|
||||
: ({
|
||||
auto dstPath = TRY_AWAIT(fetchToStore(
|
||||
*store,
|
||||
checkSourcePath(path),
|
||||
path.baseName(),
|
||||
FileIngestionMethod::Recursive,
|
||||
nullptr,
|
||||
repair
|
||||
));
|
||||
allowPath(dstPath);
|
||||
srcToStore.insert_or_assign(path, dstPath);
|
||||
printMsg(lvlChatty, "copied source '%1%' -> '%2%'", path, store->printStorePath(dstPath));
|
||||
return dstPath;
|
||||
}();
|
||||
std::move(dstPath);
|
||||
});
|
||||
|
||||
context.insert(NixStringContextElem::Opaque {
|
||||
.path = dstPath
|
||||
|
||||
@@ -1557,14 +1557,14 @@ static void addPath(
|
||||
});
|
||||
|
||||
if (!expectedHash || !state.ctx.store->isValidPath(*expectedStorePath)) {
|
||||
auto dstPath = fetchToStore(
|
||||
auto dstPath = state.aio.blockOn(fetchToStore(
|
||||
*state.ctx.store,
|
||||
state.ctx.paths.checkSourcePath(CanonPath(path)),
|
||||
name,
|
||||
method,
|
||||
&filter,
|
||||
state.ctx.repair
|
||||
);
|
||||
));
|
||||
if (expectedHash && expectedStorePath != dstPath)
|
||||
state.ctx.errors.make<EvalError>(
|
||||
"store path mismatch in (possibly filtered) path added from '%s'",
|
||||
|
||||
@@ -4,22 +4,24 @@
|
||||
|
||||
namespace nix {
|
||||
|
||||
StorePath fetchToStore(
|
||||
kj::Promise<Result<StorePath>> fetchToStore(
|
||||
Store & store,
|
||||
const CheckedSourcePath & path,
|
||||
std::string_view name,
|
||||
FileIngestionMethod method,
|
||||
PathFilter * filter,
|
||||
RepairFlag repair)
|
||||
{
|
||||
try {
|
||||
Activity act(*logger, lvlChatty, actUnknown, fmt("copying '%s' to the store", path));
|
||||
|
||||
auto filter2 = filter ? *filter : defaultPathFilter;
|
||||
|
||||
return
|
||||
co_return
|
||||
settings.readOnlyMode
|
||||
? store.computeStorePathForPath(name, path.canonical().abs(), method, HashType::SHA256, filter2).first
|
||||
: store.addToStore(name, path.canonical().abs(), method, HashType::SHA256, filter2, repair);
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace nix {
|
||||
/**
|
||||
* Copy the `path` to the Nix store.
|
||||
*/
|
||||
StorePath fetchToStore(
|
||||
kj::Promise<Result<StorePath>> fetchToStore(
|
||||
Store & store,
|
||||
const CheckedSourcePath & path,
|
||||
std::string_view name = "source",
|
||||
|
||||
Reference in New Issue
Block a user