diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2022-03-01 18:31:36 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2022-03-03 19:01:25 +0000 |
commit | 6636202356b94ca4128462493770e7fedf997b0e (patch) | |
tree | 94425988649343830763bacb1b3a5bdf4fcff1df /src/nix/store-gc.cc | |
parent | 391f4fcabe6c307afeb2f39dec07d43f1e6bf748 (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/store-gc.cc')
-rw-r--r-- | src/nix/store-gc.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/nix/store-gc.cc b/src/nix/store-gc.cc index a2d74066e..21718dc0c 100644 --- a/src/nix/store-gc.cc +++ b/src/nix/store-gc.cc @@ -2,6 +2,7 @@ #include "common-args.hh" #include "shared.hh" #include "store-api.hh" +#include "gc-store.hh" using namespace nix; @@ -33,10 +34,12 @@ struct CmdStoreGC : StoreCommand, MixDryRun void run(ref<Store> store) override { + auto & gcStore = requireGcStore(*store); + options.action = dryRun ? GCOptions::gcReturnDead : GCOptions::gcDeleteDead; GCResults results; PrintFreed freed(options.action == GCOptions::gcDeleteDead, results); - store->collectGarbage(options, results); + gcStore.collectGarbage(options, results); } }; |