about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMatthew O'Gorman <mog@rldn.net>2018-03-02T03·59-0500
committerMatthew O'Gorman <mog@rldn.net>2018-03-02T03·59-0500
commit467fdd8ca4d63972dbd94f0496918522c58916a0 (patch)
tree35b9fecc948d238e1a24ae9bd063459bfd7c111f /src
parent3c16044cb0acc87e128534cb3e2a2006b71059b6 (diff)
only delete things older than current gen and update logic in doc as
well
Diffstat (limited to 'src')
-rw-r--r--src/libstore/profiles.cc13
1 files changed, 9 insertions, 4 deletions
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<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);
+        }
     }
 }