libstore: asyncify createGeneration
Change-Id: Iae47a0f732b2f0fe54525917c091169f4be2214e
This commit is contained in:
@@ -795,10 +795,10 @@ static void opSet(Globals & globals, Strings opFlags, Strings opArgs)
|
||||
);
|
||||
|
||||
debug("switching to new user environment");
|
||||
Path generation = createGeneration(
|
||||
Path generation = globals.aio.blockOn(createGeneration(
|
||||
*store2,
|
||||
globals.profile,
|
||||
drv.queryOutPath(*state));
|
||||
drv.queryOutPath(*state)));
|
||||
switchLink(globals.profile, generation);
|
||||
}
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
|
||||
}
|
||||
|
||||
debug("switching to new user environment");
|
||||
Path generation = createGeneration(*store2, profile, topLevelOut);
|
||||
Path generation = state.aio.blockOn(createGeneration(*store2, profile, topLevelOut));
|
||||
switchLink(profile, generation);
|
||||
}
|
||||
|
||||
|
||||
@@ -231,7 +231,7 @@ void MixProfile::updateProfile(const StorePath & storePath)
|
||||
if (!store) throw Error("'--profile' is not supported for this Nix store");
|
||||
auto profile2 = absPath(*profile);
|
||||
switchLink(profile2,
|
||||
createGeneration(*store, profile2, storePath));
|
||||
aio().blockOn(createGeneration(*store, profile2, storePath)));
|
||||
}
|
||||
|
||||
void MixProfile::updateProfile(const BuiltPaths & buildables)
|
||||
|
||||
@@ -70,8 +70,8 @@ static Path makeName(const Path & profile, GenerationNumber num)
|
||||
}
|
||||
|
||||
|
||||
Path createGeneration(LocalFSStore & store, Path profile, StorePath outPath)
|
||||
{
|
||||
kj::Promise<Result<Path>> createGeneration(LocalFSStore & store, Path profile, StorePath outPath)
|
||||
try {
|
||||
/* The new generation number should be higher than old the
|
||||
previous ones. */
|
||||
auto [gens, dummy] = findGenerations(profile);
|
||||
@@ -87,7 +87,7 @@ Path createGeneration(LocalFSStore & store, Path profile, StorePath outPath)
|
||||
This helps keeping gratuitous installs/rebuilds from piling
|
||||
up uncontrolled numbers of generations, cluttering up the
|
||||
UI like grub. */
|
||||
return last.path;
|
||||
co_return last.path;
|
||||
}
|
||||
|
||||
num = last.number;
|
||||
@@ -104,7 +104,9 @@ Path createGeneration(LocalFSStore & store, Path profile, StorePath outPath)
|
||||
Path generation = makeName(profile, num + 1);
|
||||
store.addPermRoot(outPath, generation);
|
||||
|
||||
return generation;
|
||||
co_return generation;
|
||||
} catch (...) {
|
||||
co_return result::current_exception();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ class LocalFSStore;
|
||||
* The behavior of reusing existing generations like this makes this
|
||||
* procedure idempotent. It also avoids clutter.
|
||||
*/
|
||||
Path createGeneration(LocalFSStore & store, Path profile, StorePath outPath);
|
||||
kj::Promise<Result<Path>> createGeneration(LocalFSStore & store, Path profile, StorePath outPath);
|
||||
|
||||
/**
|
||||
* Unconditionally delete a generation
|
||||
|
||||
@@ -257,7 +257,8 @@ struct CmdUpgradeNix : MixDryRun, EvalCommand
|
||||
// Build the new profile, and switch to it.
|
||||
StorePath const newProfile = manifest.build(store);
|
||||
printTalkative("built new profile '%s'", store->printStorePath(newProfile));
|
||||
auto const newGeneration = createGeneration(*fsStore, this->profileDir, newProfile);
|
||||
auto const newGeneration =
|
||||
aio().blockOn(createGeneration(*fsStore, this->profileDir, newProfile));
|
||||
printTalkative(
|
||||
"switching '%s' to newly created generation '%s'",
|
||||
this->profileDir,
|
||||
|
||||
Reference in New Issue
Block a user