libstore: asyncify copyClosure
Change-Id: I18cc324d80b502ac87dda3fba2166d4e25f53664
This commit is contained in:
@@ -324,7 +324,9 @@ connected:
|
||||
if (!result.success())
|
||||
throw Error("build of '%s' on '%s' failed: %s", store->printStorePath(*drvPath), storeUri, result.errorMsg);
|
||||
} else {
|
||||
copyClosure(*store, *sshStore, StorePathSet {*drvPath}, NoRepair, NoCheckSigs, substitute);
|
||||
aio.blockOn(copyClosure(
|
||||
*store, *sshStore, StorePathSet{*drvPath}, NoRepair, NoCheckSigs, substitute
|
||||
));
|
||||
auto res = aio.blockOn(sshStore->buildPathsWithResults({
|
||||
DerivedPath::Built {
|
||||
.drvPath = makeConstantStorePathRef(*drvPath),
|
||||
|
||||
@@ -55,7 +55,7 @@ static int main_nix_copy_closure(AsyncIoRoot & aio, std::string programName, Str
|
||||
for (auto & path : storePaths)
|
||||
storePaths2.insert(from->followLinksToStorePath(path));
|
||||
|
||||
copyClosure(*from, *to, storePaths2, NoRepair, NoCheckSigs, useSubstitutes);
|
||||
aio.blockOn(copyClosure(*from, *to, storePaths2, NoRepair, NoCheckSigs, useSubstitutes));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ try {
|
||||
}
|
||||
}
|
||||
|
||||
if (store != buildStore) copyClosure(*buildStore, *store, outputsToCopyAndAllow);
|
||||
if (store != buildStore) TRY_AWAIT(copyClosure(*buildStore, *store, outputsToCopyAndAllow));
|
||||
if (allowedPaths) {
|
||||
for (auto & outputPath : outputsToCopyAndAllow) {
|
||||
/* Add the output of this derivations to the allowed
|
||||
|
||||
@@ -67,7 +67,7 @@ static void runFetchClosureWithRewrite(EvalState & state, const PosIdx pos, Stor
|
||||
static void runFetchClosureWithContentAddressedPath(EvalState & state, const PosIdx pos, Store & fromStore, const StorePath & fromPath, Value & v) {
|
||||
|
||||
if (!state.ctx.store->isValidPath(fromPath))
|
||||
copyClosure(fromStore, *state.ctx.store, RealisedPath::Set { fromPath });
|
||||
state.aio.blockOn(copyClosure(fromStore, *state.ctx.store, RealisedPath::Set { fromPath }));
|
||||
|
||||
auto info = state.ctx.store->queryPathInfo(fromPath);
|
||||
|
||||
@@ -93,7 +93,7 @@ static void runFetchClosureWithContentAddressedPath(EvalState & state, const Pos
|
||||
static void runFetchClosureWithInputAddressedPath(EvalState & state, const PosIdx pos, Store & fromStore, const StorePath & fromPath, Value & v) {
|
||||
|
||||
if (!state.ctx.store->isValidPath(fromPath))
|
||||
copyClosure(fromStore, *state.ctx.store, RealisedPath::Set { fromPath });
|
||||
state.aio.blockOn(copyClosure(fromStore, *state.ctx.store, RealisedPath::Set { fromPath }));
|
||||
|
||||
auto info = state.ctx.store->queryPathInfo(fromPath);
|
||||
|
||||
|
||||
@@ -436,7 +436,7 @@ try {
|
||||
for (auto & i : drv->inputSrcs)
|
||||
if (worker.evalStore.isValidPath(i))
|
||||
inputSrcs.insert(i);
|
||||
copyClosure(worker.evalStore, worker.store, inputSrcs);
|
||||
TRY_AWAIT(copyClosure(worker.evalStore, worker.store, inputSrcs));
|
||||
}
|
||||
|
||||
for (auto & i : drv->inputSrcs) {
|
||||
|
||||
@@ -590,10 +590,10 @@ std::shared_ptr<const Realisation> RemoteStore::queryRealisationUncached(const D
|
||||
}
|
||||
}
|
||||
|
||||
void RemoteStore::copyDrvsFromEvalStore(
|
||||
kj::Promise<Result<void>> RemoteStore::copyDrvsFromEvalStore(
|
||||
const std::vector<DerivedPath> & paths,
|
||||
std::shared_ptr<Store> evalStore)
|
||||
{
|
||||
try {
|
||||
if (evalStore && evalStore.get() != this) {
|
||||
/* The remote doesn't have a way to access evalStore, so copy
|
||||
the .drvs. */
|
||||
@@ -608,15 +608,18 @@ void RemoteStore::copyDrvsFromEvalStore(
|
||||
},
|
||||
}, i.raw());
|
||||
}
|
||||
copyClosure(*evalStore, *this, drvPaths2);
|
||||
TRY_AWAIT(copyClosure(*evalStore, *this, drvPaths2));
|
||||
}
|
||||
co_return result::success();
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
kj ::Promise<Result<void>> RemoteStore::buildPaths(
|
||||
const std::vector<DerivedPath> & drvPaths, BuildMode buildMode, std::shared_ptr<Store> evalStore
|
||||
)
|
||||
try {
|
||||
copyDrvsFromEvalStore(drvPaths, evalStore);
|
||||
TRY_AWAIT(copyDrvsFromEvalStore(drvPaths, evalStore));
|
||||
|
||||
auto conn(getConnection());
|
||||
conn->to << WorkerProto::Op::BuildPaths;
|
||||
@@ -624,9 +627,9 @@ try {
|
||||
conn->to << buildMode;
|
||||
conn.processStderr();
|
||||
readInt(conn->from);
|
||||
return {result::success()};
|
||||
co_return result::success();
|
||||
} catch (...) {
|
||||
return {result::current_exception()};
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
kj::Promise<Result<std::vector<KeyedBuildResult>>> RemoteStore::buildPathsWithResults(
|
||||
@@ -634,7 +637,7 @@ kj::Promise<Result<std::vector<KeyedBuildResult>>> RemoteStore::buildPathsWithRe
|
||||
BuildMode buildMode,
|
||||
std::shared_ptr<Store> evalStore)
|
||||
try {
|
||||
copyDrvsFromEvalStore(paths, evalStore);
|
||||
TRY_AWAIT(copyDrvsFromEvalStore(paths, evalStore));
|
||||
|
||||
std::optional<ConnectionHandle> conn_(getConnection());
|
||||
auto & conn = *conn_;
|
||||
|
||||
@@ -196,7 +196,7 @@ private:
|
||||
|
||||
std::atomic_bool failed{false};
|
||||
|
||||
void copyDrvsFromEvalStore(
|
||||
kj::Promise<Result<void>> copyDrvsFromEvalStore(
|
||||
const std::vector<DerivedPath> & paths,
|
||||
std::shared_ptr<Store> evalStore);
|
||||
};
|
||||
|
||||
@@ -1288,35 +1288,41 @@ std::map<StorePath, StorePath> copyPaths(
|
||||
return pathsMap;
|
||||
}
|
||||
|
||||
void copyClosure(
|
||||
kj::Promise<Result<void>> copyClosure(
|
||||
Store & srcStore,
|
||||
Store & dstStore,
|
||||
const RealisedPath::Set & paths,
|
||||
RepairFlag repair,
|
||||
CheckSigsFlag checkSigs,
|
||||
SubstituteFlag substitute)
|
||||
{
|
||||
if (&srcStore == &dstStore) return;
|
||||
try {
|
||||
if (&srcStore == &dstStore) return {result::success()};
|
||||
|
||||
RealisedPath::Set closure;
|
||||
RealisedPath::closure(srcStore, paths, closure);
|
||||
|
||||
copyPaths(srcStore, dstStore, closure, repair, checkSigs, substitute);
|
||||
return {result::success()};
|
||||
} catch (...) {
|
||||
return {result::current_exception()};
|
||||
}
|
||||
|
||||
void copyClosure(
|
||||
kj::Promise<Result<void>> copyClosure(
|
||||
Store & srcStore,
|
||||
Store & dstStore,
|
||||
const StorePathSet & storePaths,
|
||||
RepairFlag repair,
|
||||
CheckSigsFlag checkSigs,
|
||||
SubstituteFlag substitute)
|
||||
{
|
||||
if (&srcStore == &dstStore) return;
|
||||
try {
|
||||
if (&srcStore == &dstStore) return {result::success()};
|
||||
|
||||
StorePathSet closure;
|
||||
srcStore.computeFSClosure(storePaths, closure);
|
||||
copyPaths(srcStore, dstStore, closure, repair, checkSigs, substitute);
|
||||
return {result::success()};
|
||||
} catch (...) {
|
||||
return {result::current_exception()};
|
||||
}
|
||||
|
||||
std::optional<ValidPathInfo> decodeValidPathInfo(const Store & store, std::istream & str, std::optional<HashResult> hashGiven)
|
||||
|
||||
@@ -938,14 +938,14 @@ std::map<StorePath, StorePath> copyPaths(
|
||||
/**
|
||||
* Copy the closure of `paths` from `srcStore` to `dstStore`.
|
||||
*/
|
||||
void copyClosure(
|
||||
kj::Promise<Result<void>> copyClosure(
|
||||
Store & srcStore, Store & dstStore,
|
||||
const RealisedPath::Set & paths,
|
||||
RepairFlag repair = NoRepair,
|
||||
CheckSigsFlag checkSigs = CheckSigs,
|
||||
SubstituteFlag substitute = NoSubstitute);
|
||||
|
||||
void copyClosure(
|
||||
kj::Promise<Result<void>> copyClosure(
|
||||
Store & srcStore, Store & dstStore,
|
||||
const StorePathSet & paths,
|
||||
RepairFlag repair = NoRepair,
|
||||
|
||||
Reference in New Issue
Block a user