createGeneration(): Take a StorePath

This commit is contained in:
Eelco Dolstra 2020-09-03 11:06:56 +02:00
parent 94a043ff3b
commit b74f5cdd23
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
5 changed files with 12 additions and 7 deletions

View file

@ -72,7 +72,7 @@ static void makeName(const Path & profile, GenerationNumber num,
} }
Path createGeneration(ref<LocalFSStore> store, Path profile, Path outPath) Path createGeneration(ref<LocalFSStore> store, Path profile, StorePath outPath)
{ {
/* The new generation number should be higher than old the /* The new generation number should be higher than old the
previous ones. */ previous ones. */
@ -82,7 +82,7 @@ Path createGeneration(ref<LocalFSStore> store, Path profile, Path outPath)
if (gens.size() > 0) { if (gens.size() > 0) {
Generation last = gens.back(); Generation last = gens.back();
if (readLink(last.path) == outPath) { if (readLink(last.path) == store->printStorePath(outPath)) {
/* We only create a new generation symlink if it differs /* We only create a new generation symlink if it differs
from the last one. from the last one.
@ -105,7 +105,7 @@ Path createGeneration(ref<LocalFSStore> store, Path profile, Path outPath)
user environment etc. we've just built. */ user environment etc. we've just built. */
Path generation; Path generation;
makeName(profile, num + 1, generation); makeName(profile, num + 1, generation);
store->addPermRoot(store->parseStorePath(outPath), generation, false, true); store->addPermRoot(outPath, generation, false, true);
return generation; return generation;
} }

View file

@ -8,6 +8,8 @@
namespace nix { namespace nix {
class StorePath;
typedef unsigned int GenerationNumber; typedef unsigned int GenerationNumber;
@ -28,7 +30,7 @@ std::pair<Generations, std::optional<GenerationNumber>> findGenerations(Path pro
class LocalFSStore; class LocalFSStore;
Path createGeneration(ref<LocalFSStore> store, Path profile, Path outPath); Path createGeneration(ref<LocalFSStore> store, Path profile, StorePath outPath);
void deleteGeneration(const Path & profile, GenerationNumber gen); void deleteGeneration(const Path & profile, GenerationNumber gen);

View file

@ -708,7 +708,9 @@ static void opSet(Globals & globals, Strings opFlags, Strings opArgs)
} }
debug(format("switching to new user environment")); debug(format("switching to new user environment"));
Path generation = createGeneration(ref<LocalFSStore>(store2), globals.profile, drv.queryOutPath()); Path generation = createGeneration(
ref<LocalFSStore>(store2), globals.profile,
store2->parseStorePath(drv.queryOutPath()));
switchLink(globals.profile, generation); switchLink(globals.profile, generation);
} }

View file

@ -151,7 +151,8 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
} }
debug(format("switching to new user environment")); debug(format("switching to new user environment"));
Path generation = createGeneration(ref<LocalFSStore>(store2), profile, topLevelOut); Path generation = createGeneration(ref<LocalFSStore>(store2), profile,
store2->parseStorePath(topLevelOut));
switchLink(profile, generation); switchLink(profile, generation);
} }

View file

@ -134,7 +134,7 @@ void MixProfile::updateProfile(const StorePath & storePath)
switchLink(profile2, switchLink(profile2,
createGeneration( createGeneration(
ref<LocalFSStore>(store), ref<LocalFSStore>(store),
profile2, store->printStorePath(storePath))); profile2, storePath));
} }
void MixProfile::updateProfile(const Buildables & buildables) void MixProfile::updateProfile(const Buildables & buildables)