1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-08 06:53:54 +02:00

only delete things older than current gen and update logic in doc as

well
This commit is contained in:
Matthew O'Gorman 2018-03-01 22:59:00 -05:00
parent 3c16044cb0
commit 467fdd8ca4
2 changed files with 14 additions and 9 deletions

View file

@ -160,19 +160,24 @@ void deleteGenerations(const Path & profile, const std::set<unsigned int> & gens
void deleteGenerationsGreaterThan(const Path & profile, int max, bool dryRun)
{
PathLocks lock;
lockProfile(lock, profile);
int curGen;
bool fromCurGen = false;
Generations gens = findGenerations(profile, curGen);
for (auto i = gens.rbegin(); i != gens.rend(); ++i) {
if (max) {
if (i->number == curGen) {
fromCurGen = true;
max--;
continue;
}
if (i->number != curGen)
if (fromCurGen) {
if (max) {
max--;
continue;
}
deleteGeneration2(profile, i->number, dryRun);
}
}
}