aboutsummaryrefslogtreecommitdiff
path: root/src/nix-collect-garbage
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2022-03-01 18:31:36 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2022-03-03 19:01:25 +0000
commit6636202356b94ca4128462493770e7fedf997b0e (patch)
tree94425988649343830763bacb1b3a5bdf4fcff1df /src/nix-collect-garbage
parent391f4fcabe6c307afeb2f39dec07d43f1e6bf748 (diff)
Factor out a `GcStore` interface
Starts progress on #5729. The idea is that we should not have these default methods throwing "unimplemented". This is a small step in that direction. I kept `addTempRoot` because it is a no-op, rather than failure. Also, as a practical matter, it is called all over the place, while doing other tasks, so the downcasting would be annoying. Maybe in the future I could move the "real" `addTempRoot` to `GcStore`, and the existing usecases use a `tryAddTempRoot` wrapper to downcast or do nothing, but I wasn't sure whether that was a good idea so with a bias to less churn I didn't do it yet.
Diffstat (limited to 'src/nix-collect-garbage')
-rw-r--r--src/nix-collect-garbage/nix-collect-garbage.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/nix-collect-garbage/nix-collect-garbage.cc b/src/nix-collect-garbage/nix-collect-garbage.cc
index 48c030b18..4b28ea6a4 100644
--- a/src/nix-collect-garbage/nix-collect-garbage.cc
+++ b/src/nix-collect-garbage/nix-collect-garbage.cc
@@ -1,4 +1,5 @@
#include "store-api.hh"
+#include "gc-store.hh"
#include "profiles.hh"
#include "shared.hh"
#include "globals.hh"
@@ -80,10 +81,11 @@ static int main_nix_collect_garbage(int argc, char * * argv)
// Run the actual garbage collector.
if (!dryRun) {
auto store = openStore();
+ auto & gcStore = requireGcStore(*store);
options.action = GCOptions::gcDeleteDead;
GCResults results;
PrintFreed freed(true, results);
- store->collectGarbage(options, results);
+ gcStore.collectGarbage(options, results);
}
return 0;