From 467fdd8ca4d63972dbd94f0496918522c58916a0 Mon Sep 17 00:00:00 2001 From: Matthew O'Gorman Date: Thu, 1 Mar 2018 22:59:00 -0500 Subject: only delete things older than current gen and update logic in doc as well --- src/libstore/profiles.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/libstore/profiles.cc') diff --git a/src/libstore/profiles.cc b/src/libstore/profiles.cc index b43ec66f60c7..4c6af567ae6f 100644 --- a/src/libstore/profiles.cc +++ b/src/libstore/profiles.cc @@ -160,19 +160,24 @@ void deleteGenerations(const Path & profile, const std::set & 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); + } } } -- cgit 1.4.1