diff options
author | Matthew O'Gorman <mog@rldn.net> | 2018-03-01 22:59:00 -0500 |
---|---|---|
committer | Matthew O'Gorman <mog@rldn.net> | 2018-03-01 22:59:00 -0500 |
commit | 467fdd8ca4d63972dbd94f0496918522c58916a0 (patch) | |
tree | 35b9fecc948d238e1a24ae9bd063459bfd7c111f /src/libstore/profiles.cc | |
parent | 3c16044cb0acc87e128534cb3e2a2006b71059b6 (diff) |
only delete things older than current gen and update logic in doc as
well
Diffstat (limited to 'src/libstore/profiles.cc')
-rw-r--r-- | src/libstore/profiles.cc | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/libstore/profiles.cc b/src/libstore/profiles.cc index b43ec66f6..4c6af567a 100644 --- a/src/libstore/profiles.cc +++ b/src/libstore/profiles.cc @@ -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); + } } } |