about summary refs log tree commit diff
path: root/src/nix-collect-garbage
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2015-08-21T11·57+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2015-08-21T11·57+0200
commiteadb86f44726e12988d5f21b47e4c54b49b2092b (patch)
tree7bc583f1caeba82bf09f660c0367f8d33e9b24f1 /src/nix-collect-garbage
parent1d29db2a9f67af8a32b2f901a6da6697c539a50d (diff)
nix-collect-garbage: Revive --max-freed
Fixes #609.
Diffstat (limited to 'src/nix-collect-garbage')
-rw-r--r--src/nix-collect-garbage/nix-collect-garbage.cc10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/nix-collect-garbage/nix-collect-garbage.cc b/src/nix-collect-garbage/nix-collect-garbage.cc
index 253c0b53755b..bb4789aeac82 100644
--- a/src/nix-collect-garbage/nix-collect-garbage.cc
+++ b/src/nix-collect-garbage/nix-collect-garbage.cc
@@ -50,11 +50,12 @@ void removeOldGenerations(std::string dir)
 int main(int argc, char * * argv)
 {
     bool removeOld = false;
-    Strings extraArgs;
 
     return handleExceptions(argv[0], [&]() {
         initNix();
 
+        GCOptions options;
+
         parseCmdLine(argc, argv, [&](Strings::iterator & arg, const Strings::iterator & end) {
             if (*arg == "--help")
                 showManPage("nix-collect-garbage");
@@ -66,8 +67,12 @@ int main(int argc, char * * argv)
                 deleteOlderThan = getArg(*arg, arg, end);
             }
             else if (*arg == "--dry-run") dryRun = true;
+            else if (*arg == "--max-freed") {
+                long long maxFreed = getIntArg<long long>(*arg, arg, end, true);
+                options.maxFreed = maxFreed >= 0 ? maxFreed : 0;
+            }
             else
-                extraArgs.push_back(*arg);
+                return false;
             return true;
         });
 
@@ -77,7 +82,6 @@ int main(int argc, char * * argv)
         // Run the actual garbage collector.
         if (!dryRun) {
             store = openStore(false);
-            GCOptions options;
             options.action = GCOptions::gcDeleteDead;
             GCResults results;
             PrintFreed freed(true, results);